When Base64 images are useful
Normally a web page links to a separate image file. A Base64 data URI puts the image inside the text instead, which is handy in a few specific cases:
- Small icons and logos in HTML or CSS. A tiny arrow, a loading spinner or a 2 KB logo saves the browser an extra request.
- Single-file documents. An HTML report, an offline page or an email template that has to work as one file, without an images folder.
- APIs and JSON. Many services ask for an image as a Base64 field — for example when uploading a profile picture, sending a document scan or calling an image-recognition API.
- Email signatures and newsletters. Some editors accept an image only as a data URI. Note that several email apps (Outlook and Gmail among them) block or strip embedded data URIs, so test before sending to everyone.
- Favicons and SVG in CSS. A small ICO or SVG can be written directly into a stylesheet.
Which format should I choose?
| Format | Looks like | Use it for |
|---|---|---|
| Data URI | data:image/png;base64,iVBOR… | img src, CSS url(), Markdown, most JSON fields |
| Base64 only | iVBORw0KGgo… | API fields that ask for the bare code and send the type separately |
| HTML img tag | an img element with the data URI as src | Pasting straight into an HTML page or email template |
| CSS rule | background-image with url("data:…") | Stylesheets, inline style attributes |
If you are not sure, choose Data URI — it works in the most places. For copy-ready examples and size advice, see How to embed an image in HTML or CSS with Base64. Got Base64 code and need the picture back? Use Base64 to image.
Keep it small
Base64 is best for small images. A rough rule of thumb:
- Under 10 KB (icons, simple logos): embedding is a good idea.
- 10–100 KB: fine for single-file documents and emails, less so on a web page that is loaded often.
- Over 100 KB: usually better as a normal image file. The text is a third larger than the image, it can't be cached separately, and it delays the rest of the page.
To shrink a picture before converting, use Compress PNG or Compress JPG, or reduce its pixel size with Resize image. For icons and logos, an SVG is often the smallest option of all.
If something goes wrong
"This image couldn't be opened." The file is not one of the supported image types, or it is damaged. iPhone HEIC photos can't be shown in most browsers as a data URI — convert them to JPG first.
"This image is larger than 10 MB." Text that long is impractical to paste into any editor or form. Compress or resize the image first.
The image doesn't show where I pasted it. Check that you copied the whole text (long results are easy to cut short — downloading the .txt file avoids that) and that the place you pasted it into accepts data URIs; some email apps and content filters remove them on purpose.