v149 · JavaScript

Binary File Tools

Drop any small file onto the page. The demo reads it as a Uint8Array, encodes to base64 via toBase64() and hex via toHex(), and shows both outputs — all client-side, nothing uploaded.

Feature detection: checking…
Drop a file here or click to choose (images, text, JSON, SVG — keep it small!)
Name: Size: Type: Base64 length: Hex length:
// Read file as ArrayBuffer, wrap in Uint8Array
const file = event.target.files[0];
const buf  = await file.arrayBuffer();
const arr  = new Uint8Array(buf);

// ① Base64                (NEW in Chrome 149)
const b64 = arr.toBase64();

// ② URL-safe base64       (NEW in Chrome 149)
const b64url = arr.toBase64({ alphabet: "base64url" });

// ③ Hex string            (NEW in Chrome 149)
const hex = arr.toHex();

// Build data URL for images
const dataUrl = `data:${file.type};base64,${b64}`;
img.src = dataUrl;

see also

implementation reference

Need the exact API surface, compatibility boundaries, errors, lifecycle, and source links? Read the matching gendn reference ↗