Skip to content

edge-64

Edge/Workers-native base64 <-> image conversion. Uses only fetch, atob/btoa and ArrayBuffer — no Node fs, axios, or request assumptions, so it runs on Cloudflare Workers, Deno, browsers, and Node alike.

By ProFlare.

Existing packages (image-to-base64, base64-img, node-base64-image) assume a Node environment with filesystem access. This library targets edge runtimes first, with MIME type detection from magic bytes rather than trusting file extensions or content-type headers alone.

Terminal window
npm install edge64
import { imageUrlToBase64 } from "edge64";
const { mime, base64, dataUri } = await imageUrlToBase64("https://example.com/cat.png");

See API for the full reference and Examples for a Cloudflare Worker walkthrough.