Data URL Converter

Convert files and text to data URLs and back. Free, fast, and works entirely in your browser with no sign-up required.

Updated

Share:
Home/Data URL Converter

Data URL Converter

Convert files to data URLs and back, preview embedded content, generate code snippets, batch-process files, validate data URIs, and more.

Data URLs embed file content directly in strings — useful for small assets, email, SVG icons, and offline apps. Format: data:[mime];[encoding],[data]

Upload File

Drop a file here or click to browse

Images, audio, video, text, JSON, SVG, PDF…

Frequently Asked Questions

What is a data URL and how is it different from a normal file URL?

A data URL embeds a file's actual contents inside the URL itself, using the format data:[mime];[encoding],[data] — so a small image, SVG icon, or snippet of JSON lives directly in your HTML, CSS, or JavaScript. A normal file URL, by contrast, just points to a separate resource the browser must fetch over a new HTTP request. The practical trade-off is requests versus weight: a data URL removes the round trip and works offline or inside a single self-contained file, but it inflates the markup and cannot be cached independently by the browser. That makes data URLs ideal for tiny, rarely changing assets and a poor fit for large files. Paste a file or data URL into this converter to generate or decode one and see its exact size in either direction.

What is the difference between Base64 and URL-encoded data URLs?

Both encodings let a data URL carry binary or text content safely, but they work differently. Base64 maps every three bytes to four ASCII characters from a fixed 64-symbol alphabet, so it handles any binary file reliably and is the standard choice for images, audio, video, and PDFs. URL-encoding instead replaces only unsafe characters with percent-escapes like %20, which keeps already-readable text — such as SVG markup or plain JSON — compact and human-legible, often smaller than Base64 for those formats. The rule of thumb: use Base64 for true binary assets and URL-encoding for text and SVG, where it can save bytes and stays inspectable. This converter offers both formats on a single toggle for files and text, so you can generate either and compare the resulting size before you decide which to embed.

How much bigger does Base64 make a file in a data URL?

Base64 encoding adds roughly 33% to a file's size, because it represents every three bytes of data using four ASCII characters — a 4:3 ratio that is inherent to the format, not a flaw in any particular tool. On top of that, a data URL adds a short header (the data: prefix, MIME type, and ;base64, marker), so the finished string is slightly larger still. For a tiny icon those extra bytes are negligible and easily outweighed by skipping an HTTP request, but for a large file the inflation is real and the asset also can't be cached separately. This converter shows the original size next to the data URL size and reports the exact overhead in both bytes and percent for every conversion, so you can judge at a glance whether inlining is actually worth it.

When should I inline an image as a data URL instead of hosting it as a file?

Inlining works best for small, static assets — icons, logos, inline SVGs, and tiny background images — where eliminating a separate HTTP request outweighs the roughly 33% Base64 overhead and the loss of independent browser caching. It also helps when you need a single self-contained file, an offline page, or an image embedded directly in an email or generated document. Hosting a normal file is the better choice for large images, anything that changes often, or assets reused across many pages, because the browser can then cache them once and reload them instantly elsewhere. A useful threshold: data URLs over about 32 KB usually perform worse than an external file. This converter's validator flags that 32 KB mark (and warns again past 2 MB), so paste your data URL in to check whether inlining still makes sense.

Why does my data URL show the wrong MIME type, and how do I fix it?

A data URL's MIME type comes from whatever the browser detected when the file was read, and that guess is occasionally wrong — an SVG saved with a generic extension, for example, may be reported as text/plain or application/octet-stream instead of image/svg+xml. Because the MIME type tells the browser how to render the content, an incorrect one can stop an image from displaying or a file from downloading with the right extension. The fix is simply to set the type explicitly rather than trusting auto-detection. This converter auto-detects the MIME type from each file but lets you override it manually, with common types suggested as you type, so you can force the correct value before copying. Set the right MIME type, regenerate the data URL, and your inline asset will render and download exactly as intended.

About the Data URL Converter

The Data URL Converter turns files and text into data URLs and decodes them back into downloadable files, all in one place. A data URL embeds a file's contents directly inside a string using the format data:[<mime>][;<encoding>],<data> — so a small PNG, an SVG icon, or a snippet of JSON can live inside your HTML, CSS, or JavaScript with no separate HTTP request. Front-end developers, email designers, and anyone debugging an inline asset reach for a converter like this when they need to inline a resource quickly or unpack one someone else has already encoded.

Everything happens locally in your browser. Files are read with the browser's FileReader API and never leave your device, so there is no upload, no sign-up, and no size quota imposed by a server. That matters when the file is a private logo, an internal document, or a customer asset you would rather not send to a third party.

Encode files, text, or code

Drag a file onto the drop zone — or browse for it — and the tool produces a data URL in either Base64 or URL-encoded form. It auto-detects the MIME type from the file, and you can override it manually (for example, forcing image/svg+xml on a file the browser misreads). A separate Text → Data URL tab encodes raw markup or code directly: paste an SVG, JSON object, HTML page, or CSV, pick a MIME type, and copy the result. Built-in presets for SVG, JSON, HTML, and CSV give you a working starting point in one click.

Every encode shows the original size next to the data URL size, plus the exact Base64 overhead. Base64 inflates binary data by roughly 33% because it represents three bytes as four ASCII characters, and the tool reports that overhead in both bytes and percent so you can judge whether inlining is worth it.

Decode, preview, and validate

Paste any data URL into the decoder to inspect it and download the original file with a sensible extension derived from its MIME type. The Preview tab renders the content live — images, audio, video, SVG, and PDF display inline, and text-based formats are decoded and shown as readable source. The Validator inspects a data URL against the spec and flags problems: a missing data: prefix, malformed structure, invalid Base64 characters, or an unknown encoding. It also warns when a data URL crosses practical thresholds — over 32 KB, where an external file usually performs better, and over 2 MB, where some browsers struggle.

Generate ready-to-use code snippets

Once a file or data URL is loaded, the Snippets tab writes copy-paste code for embedding it in HTML, CSS, JavaScript, React/JSX, Python, and Markdown. The snippet adapts to the content type: an image becomes an <img> tag or a background-image rule, audio and video become <source> elements, and other files become download links. The JavaScript and Python examples show how to convert a data URL back into a Blob or write the decoded bytes to disk, which is handy when you only need the underlying file.

Batch conversion and history

For more than one file, the Batch tab converts a whole selection at once, showing per-file success or failure and the size change for each, with a one-click option to copy every resulting URL. A History panel keeps your recent conversions during the session — up to 20 — so you can restore, re-copy, or download an earlier result without redoing the work. Because history lives only in the current page, it clears when you close the tab, keeping your data private.

A practical rule of thumb: data URLs shine for small, rarely changing assets like icons and inline SVGs, where saving a request outweighs the encoding overhead. For large or frequently updated files, a normal hosted URL the browser can cache independently is usually the better choice.