/tools/image-to-data-uri

Image to Data URI

Create a data:image URI from any image so it can be embedded straight into HTML, CSS or a single-file page, without a separate request for the image file.

Private & secure
Upload image or drag & drop
JPG · PNG · WebP · GIF · SVG

How to use the Image to Data URI

01
Upload
Drop an image.
02
Choose output
Plain Base64, a Data URI, CSS or an HTML tag.
03
Copy
Copy to clipboard or download as a text file.

Anatomy of a data URI

A data URI packs a whole file into an address. It has three parts: the data: scheme, the media type such as image/png or image/svg+xml, and the content, here Base64 encoded after ;base64,. Anywhere a browser accepts an image URL, in an img src, a CSS url() or an SVG image element, it accepts a data URI too.

This tool reads the file with your browser and builds the URI there, without uploading anything. Switch between Data URI, CSS and HTML to get the snippet in the shape you need, or Base64 for the bare string.

Inline or linked: the trade-off

Inlining saves a network request and guarantees the image is there the moment the HTML or CSS arrives, which is why it is popular for tiny icons, loading spinners and single-file reports. The cost is size and caching. The encoded text is about a third larger than the file, it is downloaded again with every page that includes it, and the browser can't cache it on its own.

A sensible rule is to inline only small images of a few kilobytes and keep photos as normal files. The size panel shows the encoded length and overhead so you can decide.

Using the output in HTML and CSS

The HTML option produces an img tag with an empty alt attribute. Replace it with a short description unless the image is purely decorative. The CSS option produces a background-image rule you can drop into a stylesheet. If your site uses a Content Security Policy, its img-src directive must include data: for these images to load.

Supported formats

JPGPNGWebPGIFSVG

Files up to 25 MB. Large, high-resolution photos are supported.

Privacy

This tool runs entirely in your browser. Your image is never uploaded. No account needed. How we handle files.

Image to Data URI FAQ

Do all browsers support data URIs?

Yes. Every modern browser supports data URIs for images in HTML, CSS and SVG.

Is there a maximum length for a data URI?

Modern browsers handle very long data URIs, but large ones make pages heavy and slow to parse. Keep inlined images small.

Why does my Content Security Policy block the image?

The img-src directive doesn't allow the data: scheme. Add data: to it, or serve the image as a normal file.

Can I use a data URI image in an email?

Support is patchy, and many email clients don't show them. Hosted images or attachments are more reliable.

Should I use a data URI for SVG icons?

It works, but pasting the SVG markup directly into the HTML is often smaller and lets CSS style the icon.

Are my images safe?

This tool runs entirely in your browser. Your image is never uploaded.

Is it free?

Yes. No account, no watermark and no limit on how many images you process. Files can be up to 25 MB.

Related tools

See all 8 utilities tools →