Image to Base64
Image Tools · Added
Convert an image into a Base64 data URI, with copy-ready HTML and CSS snippets. The encoding happens in your browser, and the tool shows you how much larger the file gets — because inlining trades a network request for a bigger asset, and that trade is only worth making for small images.
How to use the image to base64
- 1Choose an image, or drop it onto the box. JPG, PNG, WebP, GIF, BMP and AVIF are accepted.
- 2Pick the output you want: the bare data URI, a ready-made <img> tag, or a CSS background-image declaration.
- 3For the HTML snippet, write alt text describing the image. Leave it empty only if the image is purely decorative.
- 4Check the reported size increase. Above roughly 10 KB, a normal file the browser can cache is usually the better choice.
- 5Copy the snippet and paste it into your source.
Examples
A small icon inlined into CSS
- Input
- A 1.2 KB SVG-style PNG icon · CSS output
- Result
- background-image: url("data:image/png;base64,iVBORw0…"); — about 1.6 KB
This is what inlining is for. One fewer request, and the icon arrives with the stylesheet rather than after it.
A photograph, which should not be inlined
- Input
- A 480 KB JPEG
- Result
- About 640 KB of Base64 — a 33% increase
The tool produces it and warns you. A data URI cannot be cached on its own, so every page carrying it re-downloads the photo in full.
An image emailed as text
- Input
- A 4 KB PNG · Data URI output
- Result
- A single line beginning data:image/png;base64,
Data URIs survive anywhere plain text does, which is why they are useful for pasting an image into a JSON payload, a config file or a chat message.
About the image to base64
What inlining actually buys, and what it costs
Every separate image on a page is a request: a lookup, a connection, headers in both directions, then the bytes. For a large image that overhead is trivial next to the payload. For a 500-byte icon it can easily dominate — the negotiation costs more than the thing being negotiated for. Inlining removes it entirely by carrying the image inside the document or stylesheet that references it.
The cost is threefold and worth stating plainly. The payload grows by about a third, because Base64 spends four characters on every three bytes. The image can no longer be cached independently, so it is re-fetched with every document that carries it rather than once per visitor. And it inflates the file it sits in, which for a stylesheet means delaying every rule after it, because CSS is render-blocking and the browser cannot use any of it until the whole file has arrived.
That is why the useful rule is about size rather than taste. Below roughly ten kilobytes the removed request usually wins. Above it, the cache almost always does.
Where data URIs are genuinely the right answer
Beyond performance, a data URI is the only form of an image that survives a text-only channel. That makes it the practical way to embed an image into a JSON API response, a YAML config, an email template that must not reference an external host, or a single self-contained HTML file that has to work with no network at all.
It is also how a low-quality image placeholder works: a tiny, heavily blurred version inlined into the markup so something appears immediately, with the real image swapped in once it downloads. At that size — often under a kilobyte — the encoding overhead is irrelevant and the request saved is the entire point.
One caveat that catches people out: an SVG does not need Base64 at all. It is already text, so it can be inlined directly with URL-encoding, which avoids the 33% penalty completely and stays readable in your source. This tool handles raster images, where Base64 is the only option.
Frequently asked questions
What is a data URI?
Why is the encoded version bigger than my file?
When should I inline an image, and when should I not?
Is my image uploaded to encode it?
Does encoding change the image?
Why is there a size limit?
Related tools
Base64 Encoder / Decoder
Developer Tools
Encode text to Base64 and decode it back, with full Unicode and URL-safe support.
Image Compressor
Image Tools
Shrink JPG, PNG and WebP files with a quality slider and a live size preview.
Favicon Generator
Image Tools
Generate a full favicon set at every size a modern site needs.