Skip to main content

Data URI Inspector & Converter

Encode text or files as Data URIs, decode existing ones and compare Base64 with percent encoding.

Input

Choose a type, or keep the one from the imported file.

Text is encoded as UTF-8. Imported files up to 10 MB keep their exact bytes.

Options

Charset

Output

Nothing to convert yet
Type text, import a file or load an example to build a Data URI.

What is a Data URI?

A Data URI embeds a small file directly in a URL: data:, an optional media type such as image/svg+xml, an optional ;base64 flag, a comma and the data. Developers use Data URIs for inline icons in CSS, small images in HTML and email, test fixtures and API payloads. This tool builds them from text or files and inspects existing ones.

Base64 or percent encoding?

Base64 adds about 33% to any payload. Percent encoding keeps plain ASCII text readable but turns every escaped byte into three characters, so it is shorter for simple text and often longer for binary files or markup with many spaces and quotes. The size analysis builds both encodings, shows their exact lengths and overhead, and Auto keeps the shorter one.

How decoding works

Decoding follows RFC 2397 and the WHATWG Fetch rules that browsers use. The media type and its parameters, including charset, are read before the first comma; ;base64 is detected regardless of case; the data is percent-decoded and then Base64-decoded with whitespace ignored. A missing media type means text/plain;charset=US-ASCII. Everything after a # is a fragment and is not data, a common reason SVG Data URIs are cut short.

Safe previews and privacy

Images are previewed only for PNG, JPEG, GIF, WebP, AVIF, BMP and ICO. SVG is previewed only after unsafe elements and attributes are removed, and HTML is always shown as source text, never rendered. A MIME type taken from a file extension is labelled as inferred. Text, files and Data URIs are processed in your browser and are not uploaded or stored.

Frequently asked questions
Should I use Base64 or percent encoding for a Data URI?
It depends on the content. Base64 always adds about 33 percent, while percent encoding keeps plain text readable but turns each escaped byte into three characters. Simple text is usually shorter with percent encoding, while images, binary files and markup with many spaces and quotes are usually shorter as Base64. The tool builds both and Auto keeps the shorter one.
Why is my SVG Data URI cut off?
A # character starts the fragment of a URL, so in data:image/svg+xml,... everything after the first unescaped # (often in a color such as #16a34a) is not part of the data. Encode # as %23, or use the encoder, which escapes it automatically, and the decoder shows a warning with the number of dropped characters.
Is the decoded content uploaded or rendered?
No. Encoding, decoding and previews run in your browser and nothing is uploaded or stored. Images are previewed only for an allowlist of raster formats, SVG only after unsafe elements and attributes are removed, and HTML is always shown as source text and never rendered.

CodingTool is officially live on