ximg.es

Image to Base64

Drop an image to get its data URI and snippets ready for HTML, CSS and JSON. It works the other way too: paste a Base64 string and download the image. Everything happens in your browser.

Thumbnail of the converted image

icono.svg · image/svg+xml · 16 × 16 px · 121 B → 190 B as a data URI (+57 %)

SVG encoding

Base64 to image

What a data URI is

It’s a way of putting a file inside the code itself instead of linking to it: data:image/png;base64,iVBORw0…. The browser reads it as if it were a URL, so it works anywhere an image address would go: the src of an <img>, a CSS url() or a field in a JSON file.

When it’s worth it (and when it isn’t)

Base64 is 33% larger than the original file and can’t be cached separately: if the image lives in your CSS, it’s downloaded again every time the CSS changes. It’s worth it for:

For photos and any large image, a normal file is better, with loading="lazy" and in WebP or AVIF.

SVG: better without Base64

An SVG is text, so it can go into the data URI almost as it is, escaping only a few characters. That “URL-encoded” version is noticeably smaller than Base64 and stays readable. When you convert an SVG, the tool lets you choose.

Privacy

The conversion uses the browser’s FileReader API: the image isn’t uploaded to any server. The test button downloads a placeholder from the ximg.es generator, such as https://ximg.es/64x64/2563eb/fff, and converts it just as if it were yours.

Frequently asked questions

How much bigger is an image in Base64?

About 33% bigger than the original file: Base64 uses 4 characters for every 3 bytes. A 30 KB image becomes roughly 40 KB.

Are my images uploaded to a server?

No. Everything happens in your browser with FileReader; you can go offline and the tool keeps working.

How do I put a Base64 image in CSS?

Inside url(), in quotes: background-image: url("data:image/png;base64,…"). The tool gives you the complete snippet.

Do Base64 images work in emails?

In Apple Mail and many mobile clients, yes; Gmail and some versions of Outlook block them. For a newsletter it’s safer to link the image with an absolute URL.

How do I convert Base64 back to an image?

Paste it into “Base64 to image”. It accepts the full data URI or just the Base64; in that case the type is worked out from the first bytes.

Is Base64 or inline SVG better?

For SVG, inline SVG code or the URL-encoded data URI is better: both are smaller than Base64 and compress better with gzip.

More tools

See all tools · Placeholder image generator