When should you embed images as Base64?
Embedding saves a separate request because the image arrives inside the HTML or CSS that is already loading. That helps with very small, frequently used graphics: a 1 KB icon, a tiny loading spinner, a placeholder or a logo in a single-file HTML report.
For anything larger it usually hurts. Base64 text is about a third bigger than the original file. An embedded image cannot be cached on its own, so it is downloaded again whenever the page or stylesheet changes, and a large data URI in CSS delays the first render. As a rule of thumb, embed images of a few kilobytes and link to everything else. Shrink files first with the Image Compressor.
Base64 is also useful when an image has to travel through a text-only channel: a JSON API field, a configuration file, a test fixture or a single self-contained HTML page you want to send to someone.
Data URI, raw Base64, CSS or HTML?
- Data URI is the full value,
data:image/png;base64,โฆ, which works anywhere a URL is expected.
- Raw Base64 is just the encoded text, without a prefix. APIs and JSON fields often expect this, with the type sent separately.
- CSS gives a ready
background-image declaration.
- HTML gives an
<img> tag with width, height and your alt text.
Email is a special case: support for data URI images varies between email apps, and some webmail services do not display them. For newsletters, host the image and link to it instead.
For SVG icons, a URL-encoded data URI (data:image/svg+xml,%3Csvgโฆ) is often smaller than Base64.
Decoding Base64 back to an image
Paste the string from a stylesheet, API response or log file into the Decode tab. You can paste a whole <img> tag or url("โฆ") line, and the data URI is extracted for you. Line breaks are ignored, and URL-safe characters (- and _) and missing = padding are handled.
The tool then checks the first bytes to find the real format, because a data URI label can be wrong. The file downloads with the matching extension. If the data is cut off, the browser cannot draw it, and the tool tells you instead of producing a broken image.
Keep in mind that decoding only restores the bytes that were encoded. If someone shrank or recompressed the image before encoding it, the decoded file has that lower quality too. To change the decoded file's format afterwards, use the Image Converter.