DEVELOPER & DATA

Data URI Encoder

Turn a local file or pasted text into a data: URI (base64 or percent-encoded) with the media type detected or set, or decode a data URI to type, size and text.

A copy-ready data URI with its length and overhead, the media type used (sniffed from the bytes, taken from the file or typed), and for decoding: media type, encoding, byte length and the text or a download.

Example: "Hello, world!" becomes data:text/plain;charset=utf-8;base64,SGVsbG8sIHdvcmxkIQ== — 57 characters for 13 bytes; a 12 KB PNG becomes a 16 KB URI that the page warns is past the 32 KB comfort zone.

v0.1.0 · last reviewed 20 September 2026
Loading the workspace…
BUILT TO BE UNDERSTOOD

A file inside a URL,
built in your browser.

How the URI is built, how the media type is chosen, and when a data URI is a bad idea.

Building the URI

RFC 2397 defines data:[media type][;base64],payload. Base64 is binary-safe and costs about a third more characters; percent-encoding keeps text readable and is used only for text types. The file is read locally with the File API and never uploaded.

Media type

The type comes from the file’s own type, from a sniff of the first bytes for PNG, JPEG, GIF, WebP, SVG, PDF and ZIP, or from the field you fill in; text types get ;charset=utf-8. Decoding reads the type back, checks it against the bytes and shows text types as text.

When not to

A data URI is parsed with every page load and cannot be cached separately, so it is best for small assets embedded in CSS or HTML; large ones are flagged, as is the 32 KB limit that some contexts still impose. Nothing leaves the browser; the same four anonymous usage counts as the rest of the site apply.

SOURCES

Last reviewed 20 September 2026. How results are checked: How we verify.