Map Extract
Free tool

Data URL generator and checker

Four modes on one page: text to data URL, file to data URL, base64 to data URL, and a checker for a data URL you already have. The result shows the type, the size before and after, a preview for images, and buttons to copy it as a CSS url() or an HTML img tag.

Runs in your browser. Nothing you enter is uploaded.

Making a data URL

  1. Pick the mode

    Text to data URL for SVG, HTML or CSS you can paste, File to data URL for an image, font, PDF or audio file up to 25 MB, Base64 to data URL if you already have base64, or Check a data URL.

  2. For text, choose type and encoding

    Pick the type, such as image/svg+xml, and either percent-encoding, which stays readable, or base64.

  3. Copy the result

    Use the output box, Copy as CSS url() or, for images, Copy as <img>.

  4. Check before you ship

    Paste any data URL into the checker to confirm its type, encoding, decoded size and length, with a preview if it is an image.

Example: a small blue square for an email template

A designer building a plain HTML email template wants a tiny coloured square inline, without hosting a file. She pastes a 107-byte SVG and chooses image/svg+xml.

Percent-encoded, the data URL is 170 characters and still readable, with spaces as %20 and the # in the colour as %23. Switching to base64 makes it 184 characters. Pasting the base64 version into the checker reports image/svg+xml, Base64, 107 bytes decoded, 184 characters long.

Input
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><rect width='8' height='8' fill='#1d4ed8'/></svg>
Type image/svg+xml, percent-encoded
Result
data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%208%208'%3E%3Crect%20width='8'%20height='8'%20fill='%231d4ed8'/%3E%3C/svg%3E
107 bytes, 170 characters

Percent-encoding or base64?

EncodingBest forSize
Percent-encodedSVG and other text, where you may want to read or edit it laterOften shorter for SVG
Base64Binary files such as PNG, fonts and PDFs, and text with lots of special charactersAbout a third larger than the original

When not to use a data URL

A data URL holds the whole file inside the address, so it cannot be cached separately and it makes the page or stylesheet that contains it bigger. Small icons and simple SVGs are a good fit; photos are not. The tool warns when a data URL passes 32 KB, because some email programs and older tools cut long data URLs off.

Nothing is hosted. The address only works where you paste it, and the file is gone if you delete that text.

Questions people ask

What is a data URL?

An address that contains the file itself instead of pointing to it, in the form data: type, optional encoding, a comma, then the data. Browsers read it like a normal file. It is useful for small images and icons in CSS, HTML or emails where a separate file would be awkward.

How do I use a data URL in CSS?

Put it inside url() wherever CSS expects an image, for example as a background-image value. The Copy as CSS url() button gives you the right form, with quotes, ready to paste into a stylesheet or an inline style attribute. Small icons suit this best; large images bloat the stylesheet.

Is there a size limit for data URLs?

Browsers handle large ones, but they slow pages down and some email programs and tools truncate them. This tool accepts files up to 25 MB, warns once a data URL passes 32 KB and suggests a normal file for anything over a few hundred kilobytes.

Do data URLs work in email?

Support is mixed. Some email programs show inline data images and others block or strip them, so test with the programs your recipients use. For anything important, such as a logo, a hosted image or an attachment referenced by the email is usually more reliable.

Where your data goes

Text and files are converted into data URLs inside the page. Files you choose are read locally and never uploaded, and nothing is hosted for you.

Checked against the tool on

Top