Skip to content

Image to Base64 - Encode Images as Data URLs

Encode an image as Base64

Drop an image onto the page or click to choose one. You get three things to copy: the raw Base64 string, the full data URL with its MIME type, and an <img> tag with the data URL and the file name as alt text. The file name, MIME type, original size and Base64 size are shown above them. Any format your browser can open works, including PNG, JPEG, WebP, GIF and SVG.

Using the output

In HTML, paste the img tag, or use the data URL as the src. In CSS:

.icon {
  background-image: url("data:image/png;base64,iVBORw0KGgo...");
}

For SVG icons, Base64 is not the smallest option. A URL-encoded SVG data URI is shorter and still readable; the SVG optimiser produces one after minifying the file. Shrink large images with the image compressor before encoding them.

Related Tools

Frequently Asked Questions

What is a Base64 image?
The image file's bytes written as text, wrapped in a data URL such as data:image/png;base64,iVBORw0KGgo... You can put that string anywhere an image URL goes: an img src, a CSS url(), or a JSON field. The browser decodes it back into the image.
When is embedding an image as Base64 worth it?
For small images where saving a request matters more than size: a few icons in a CSS file, a placeholder in a single-file HTML export, or an image inside a JSON payload. For anything over a few KB, a normal file is better. It is cached separately, loads in parallel and does not bloat your HTML or CSS.
How much bigger is the Base64 version?
About a third bigger, because every 3 bytes become 4 characters. A 30 KB image becomes about 40 KB of text. The page shows both sizes. Gzip wins most of that back when the HTML or CSS is served compressed, but the image still cannot be cached on its own, so it is downloaded again whenever that file changes.
Do Base64 images work in email?
Unreliably. Gmail strips data URL images, and Outlook on Windows often blocks them. For email, host the image and link to it, or attach it and reference it by Content-ID (cid:).
Is my image uploaded?
No. The browser's FileReader API reads and encodes the file locally.