How to use it
- Click the drop zone, drop an image file onto it, or paste an image from your clipboard.
- Pick the Output: Data URI, Base64 only, CSS background, HTML <img> or Markdown.
- Copy the result or Download it as a text file. The Preview tab shows the image rebuilt from the Base64, so you can check it decoded correctly.
Encoding the 192×192 Tidypane icon gives 28.3 KB → 37.8 KB of Base64 (+33%) · image/png, and the output starts like this:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAA…
The other formats wrap the same data:
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA…");
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAA…" alt="logo" />
The alt text comes from the file name, with quotes and angle brackets removed so it can’t break the attribute.
The size trade-off
A data URI saves one HTTP request but costs about a third more bytes, and those bytes are repeated in every page or stylesheet that includes them. Browsers also can’t cache the image separately. That’s why the tool warns once the file passes about 100 KB. Inline small icons and placeholders; serve photos as files, ideally compressed with the Image Compressor.
Where data URIs are useful
- Email templates: some clients block remote images by default, but show small inline images.
- Single-file HTML reports you want to send as one attachment.
- CSS for tiny UI assets: a 1 KB icon inlined in a stylesheet avoids an extra request on first load.
- Test fixtures and mocks: an image embedded in JSON or a unit test without a separate file.
Avoid them for content images on regular web pages. The browser can’t lazy-load or cache them on their own, and every page that repeats the same data URI downloads it again.
Decoding and checking
To go the other way, paste a Base64 string or data URI into Base64 to Image. It detects the real format from the bytes, even when the declared type is wrong. For plain text rather than images, use Base64 Encode / Decode.
Doing it in code
// Browser: File → data URI
const uri = await new Promise((resolve) => {
const reader = new FileReader();
reader.onload = () => resolve(reader.result);
reader.readAsDataURL(file);
});
# Shell (macOS / Linux)
printf 'data:image/png;base64,%s' "$(base64 < logo.png | tr -d '\n')"
Frequently asked questions
Why is the Base64 version bigger than the image?
Base64 stores every 3 bytes as 4 text characters, so the result is about 33% larger than the file. A 28.3 KB PNG becomes 37.8 KB of Base64. Gzip on your server wins back part of that, but a data URI is still never smaller than the image itself.
When should I inline an image as a data URI?
For small, critical images such as an icon, a tiny logo or a CSS background under a few kilobytes, where saving a request matters more than size. For anything over about 100 KB, use a normal file: data URIs can't be cached separately, they make the HTML or CSS heavier, and the tool warns about it.
Does it work with SVG?
Yes. SVG files become data:image/svg+xml;base64 URIs. For SVG in CSS you can also use URL-encoded SVG, which is often shorter. Run the file through the SVG Optimizer first to strip editor metadata.
Is my image uploaded to convert it?
No. The file is read by your browser and encoded locally; nothing is sent to a server.
Which output format should I pick?
Data URI for src or url() attributes, Base64 only when an API or JSON field wants just the encoded bytes, CSS background for a ready-made declaration, HTML for an img tag with alt text, and Markdown for READMEs and docs.
Last updated