Encoding · Developer

Data URI generator.

Turn a file or text into a data: URI, or paste one to decode it, sniff its real type and preview it. Files are read in your browser and never uploaded.

How to create or decode a data URI

  1. To encode, choose a file or type text, set the media type and choose Base64 or percent-encoding.
  2. Press Run and copy the data: URI, or the ready-made CSS and HTML snippet.
  3. To decode, paste a data URI and press Run to see its real type, a preview and the size overhead.

When a data URI makes sense

A data URI embeds a file directly in text, so a small icon or font can live inside a stylesheet or HTML page without a separate request. This helps with tiny assets and email templates. It costs size: Base64 turns every three bytes into four characters, about a third more, and the data cannot be cached separately from the page that contains it. Percent-encoding suits short text and SVG, which stay readable and are usually smaller than Base64.

As a rule, inline only small files, a few kilobytes at most, and serve anything larger as a normal file. The tool shows the size overhead so you can judge. If you omit the media type, the standard assumes text/plain with US-ASCII, so set it for anything else.

Processed on your device

The generator runs in your browser, inside an isolated frame on this page that has no network access. Your file is read and written back by your own device, so it is not uploaded to TNAADO or anyone else, and nothing is stored. The advertising on this page sits outside the frame and cannot see what you choose. Files you choose are read in your browser and not uploaded.

How a data URI is built

RFC 2397 defines the form data:[<mediatype>][;base64],<data>. If the media type is omitted it defaults to text/plain;charset=US-ASCII. With ;base64 the payload is Base64; without it, bytes outside the safe URL range are written as %xx escapes.

Size overhead: Base64 turns every 3 bytes into 4 characters (padded), so n bytes become 4×ceil(n/3) characters, roughly 33% more (RFC 4648 section 4). Percent-encoding costs 3 characters per escaped byte, so it wins for mostly-ASCII text and SVG and loses for binary files. The RFC itself notes data URIs are only useful for short values.

MIME sniffing: when decoding, the tool checks the first bytes against the signatures in the WHATWG MIME Sniffing Standard (PNG, JPEG, GIF, WebP, WAVE, PDF) and looks for an <svg root for SVG text. It warns when the declared type and the detected type disagree. A detected type is a guess about the bytes, not proof of what the file is.

Sources: RFC 2397 — The "data" URL scheme, MDN — data: URLs, RFC 4648 section 4 — Base64, WHATWG MIME Sniffing Standard.

Frequently asked questions

Is my file uploaded?

No. The file is read with your browser's FileReader and encoded locally. Nothing is sent anywhere.

When should I use percent-encoding instead of Base64?

For short, mostly-ASCII content such as inline SVG, percent-encoding is usually smaller because Base64 always adds about a third. For binary files such as PNG or JPEG, Base64 is smaller. The result panel shows both lengths for your input.

How is this different from the Base64 text tool?

The Base64 text tool converts plain strings only. This one builds and parses the full data: URI: media type, parameters, encoding flag, file input, type detection and preview.

Worked example: "Hello, world!" as a data URI

Enter the text Hello, world! with the default text/plain type and Base64 encoding.

StepResult
UTF-8 bytes13 bytes: 48 65 6C 6C 6F 2C 20 77 6F 72 6C 64 21
Base64SGVsbG8sIHdvcmxkIQ== (20 characters)
Data URIdata:text/plain;charset=utf-8;base64,SGVsbG8sIHdvcmxkIQ==

Base64 adds about a third to the size, while percent encoding can be smaller for mostly ASCII text or SVG. Its size depends on which characters need escaping. Pasting the URI back into Decode returns the original text.

Next steps: Base64 to file, Base64 text encoder, URL encoder, or JWT decoder.

Detected type is a guess

Sniffing looks at the leading bytes only. A matching signature does not prove a file is safe or valid, and previews of untrusted data are rendered as inert images or escaped text, never executed.

Advertisement
Advertisement