Image to Data URI Converter

Convert images into a ready-to-use Data URI for CSS and HTML.

🔒 All processing happens in your browser — your files are never uploaded to a server.

About Image to Data URI

A data URI lets you put an image directly inside your HTML, CSS or JSON instead of linking to a separate file. It looks like data:image/png;base64, followed by a long string of letters and numbers that encodes the image itself. This tool creates that string for you: choose an image, press Process, and the complete data URI appears in the result box, ready to copy into an img tag, a CSS background or anywhere else a URL is accepted.

It is useful for front-end developers inlining small icons to save HTTP requests, email designers embedding logos, people building single-file HTML pages or offline demos, and anyone who needs to store a small image inside a JSON file or a database field. The tool reads the file's real type from your browser, so a PNG becomes data:image/png, an SVG becomes data:image/svg+xml, and so on. The conversion takes place on your own device; the image is never uploaded.

Why use it

  • Produces a complete data URI, including the correct MIME type prefix, in one click.
  • Works with any image your browser recognises, including PNG, JPG, GIF, WebP and SVG.
  • Keeps the original file byte for byte; the image is encoded, not recompressed or resized.
  • Ready to paste into HTML src attributes, CSS url() values, JSON or Markdown.
  • Runs locally, so logos and private images stay on your device.

How to use

  1. Choose an image

    Click the file field and select one image from your device.

  2. Press Process

    Your browser reads the file and encodes it in Base64 with its MIME type at the front.

  3. Pick a format and copy

    Choose the data URI only, a ready <img> tag or a CSS background rule, then press Copy. The original size and the data URI size are shown for comparison.

  4. Paste it into your code

    Use it as the src of an img tag, inside url() in CSS, or anywhere a normal image URL would go.

Examples

Inline icon in HTML

A 1.2 KB PNG checkmark becomes a string of about 1,650 characters. Paste it as <img src="data:image/png;base64,..."> and the icon loads with the page, without a separate request.

CSS background

A small repeating pattern is placed in a stylesheet as background-image: url("data:image/png;base64,..."), so the pattern travels with the CSS file.

Single-file demo page

A prototype with three small images is sent to a client as one HTML file. Converting each image to a data URI means nothing breaks when the file is opened offline.

Size check before inlining

A 6,000-byte PNG produces 8,000 Base64 characters plus the 22-character prefix data:image/png;base64, for 8,022 characters in total, about a third larger than the file.

What the start of the data URI looks like for common formats
Image formatData URI begins withGood candidate for inlining?
PNGdata:image/png;base64,Yes, for small icons and UI graphics
JPGdata:image/jpeg;base64,Only for small thumbnails
GIFdata:image/gif;base64,Small animations or spacers
WebPdata:image/webp;base64,Yes, if your audience's browsers support WebP
SVGdata:image/svg+xml;base64,Yes, icons and logos

Tips

  • Inline only small images, roughly a few kilobytes. Large data URIs bloat your HTML or CSS and are not cached separately by the browser.
  • Base64 makes data about 33% larger than the original file, so compress or resize the image before converting it.
  • Copy the entire string from data: to the very last character; a truncated data URI shows as a broken image.
  • Some email clients block or strip data URI images. Test in the clients your audience uses before relying on them.
  • If you only need the Base64 text without the data: prefix, delete everything up to and including the first comma.

The image is read and encoded inside your browser; it is not uploaded to any server.

Frequently asked questions

What is a data URI?

It is a URL that contains the file itself instead of pointing to it. For images it takes the form data:[type];base64,[encoded data], and browsers display it just like a normal image link.

What is the difference between a data URI and Base64?

Base64 is the encoding that turns binary data into text. A data URI is Base64 plus a prefix that tells the browser the file type, such as data:image/png;base64, so it can be used directly as an image source.

How do I use the result in HTML?

Put the whole string inside the src attribute: <img src="data:image/png;base64,..." alt="description">. Keep the alt text for accessibility.

How do I use it in CSS?

Wrap it in url(), for example background-image: url("data:image/svg+xml;base64,...");. Quotes around the value are recommended.

Which image formats are supported?

Any image file your browser can read, including PNG, JPG, GIF, WebP, SVG, BMP and ICO. The MIME type in the prefix comes from the file you choose.

Why is the data URI bigger than my image?

Base64 represents every 3 bytes as 4 text characters, so the output is about one third larger than the original file, plus the short prefix.

Is there a file size limit?

The tool sets no fixed limit, but very large images create extremely long strings that are slow to copy and impractical to embed. Data URIs work best for files of a few kilobytes.

Does converting change image quality?

No. The file is encoded exactly as it is, without compression or resizing, so decoding the data URI gives back the identical image.

Can I convert several images at once?

No, one image is processed per click. Repeat the steps for each image you need.

Do data URIs help website speed?

For a few very small images they can save HTTP requests. For larger images they usually hurt, because the data cannot be cached separately and makes the page heavier.

Is my image uploaded?

No. The browser reads the file locally and builds the string on your device.

How can I turn a data URI back into an image?

Paste it into the address bar of most browsers to view it, or use the Base64 to image tool on this site to preview and save it.

Last updated:

Share this tool:WhatsAppXTelegram