Image to Base64 Converter
Turn an image into a data URL you can paste into HTML or CSS — with the full string, a ready-made CSS snippet, and an honest count of what the embedding costs. Converted on your device, never uploaded.
Convert your image
What a data URL actually is
An image file is binary data — bytes that no text editor, HTML attribute or CSS file can hold directly. Base64 is the standard escape hatch: it re-expresses those bytes using only 64 safe characters (A–Z, a–z, 0–9, + and /), so the image can live inside text. Wrap that string in a prefix that says what it is — data:image/png;base64, — and you have a data URL: a complete image that can sit anywhere a URL can, in an <img> tag's src, a CSS background, or a JSON payload. The browser decodes it back to the identical bytes before rendering. Nothing about the image itself changes; Base64 is a costume, not a compression, and the costume is not free.
The cost is fixed by arithmetic, not by the tool: encoding works in groups of 3 bytes producing 4 characters, so the output length is 4 × ceil(bytes ÷ 3) — a growth of almost exactly one third, plus the short prefix. A 3-byte file becomes 4 characters; the 100 KB example in the panel above becomes 136,536 characters. This page shows you both numbers side by side for your own file precisely because the trade is so often made blind: developers paste a data URL into a stylesheet, the file swells by a third, and because the string is text it also tends to be copied into places (emails, documents, chat messages) where its size surprises everyone. Knowing the character count before you paste is the whole discipline.
So when does the trade make sense? The genuine wins are small and specific. A single-file HTML page — a report, a portable resume, a test page — can carry its one small logo with no companion files to lose. An email template can embed a tiny graphic without hosting it. A favicon or a 1 KB interface icon in CSS avoids a separate network request, which on a slow connection can matter more than a third of almost nothing. The losses scale with size, and they are structural: an embedded image cannot be cached independently of the page that carries it, so it is re-downloaded on every page and every visit; it cannot stream in progressively; and a large Base64 block inside HTML or CSS must be parsed and decoded before rendering proceeds. The professional rule is a size threshold — embed under a few kilobytes, link everything else — and this tool's size panel exists so you can apply that rule to your actual file rather than to a guess.
Worked examples
A 3-byte file → 4 × ceil(3 ÷ 3) = 4 characters. The smallest possible demonstration of the 3-to-4 rule.
A 100 KB file (102,400 bytes) → 4 × ceil(102,400 ÷ 3) = 136,536 characters ≈ 133.34 KB of text, before the data URL prefix. Overhead: 33.3%.
A 500 KB photograph → roughly 667 KB of text that cannot be cached — the worked example of when to link the file instead.
The overhead at a glance
| Original file | Base64 characters | Text size | Sensible? |
|---|---|---|---|
| 1 KB (1,024 bytes) | 1,368 | ≈1.34 KB | Yes — icon territory |
| 10 KB (10,240 bytes) | 13,656 | ≈13.34 KB | Borderline — small graphics only |
| 100 KB (102,400 bytes) | 136,536 | ≈133.34 KB | Rarely — link it instead |
| 1 MB (1,048,576 bytes) | 1,398,104 | ≈1.33 MB | No — a file this size must stay a file |
Frequently asked questions
How much bigger is Base64 than the original file?
Almost exactly one third bigger. Base64 represents every 3 bytes of the file as 4 text characters, so the encoded length is 4 times the byte count divided by 3, rounded up: a 3-byte file becomes 4 characters, and a 100 KB file of 102,400 bytes becomes 136,536 characters, about 133.34 KB of text. Add the short 'data:image/...;base64,' prefix and that overhead is the true cost of embedding any image as text.
When should I embed an image as a data URL?
When the image is tiny and the alternative is an extra file: a favicon-sized icon, a small logo inside a single-file HTML page or email template, a signature graphic, or a test fixture in code. The saving is one network request and one file to manage. The rule of thumb used by most developers: if the encoded string is longer than a few kilobytes, link the file instead — the overhead and the costs below grow with size while the benefit stays the same.
When is Base64 the wrong choice?
For large images, and for anything a visitor's browser should cache. A photograph embedded as Base64 is a third larger than the file, it cannot be cached separately from the page (so it is downloaded again with every page that contains it), it cannot load progressively, and a big block of it in HTML or CSS delays rendering while the browser decodes it. A 500 KB photo becomes roughly 667 KB of text with all of those disadvantages; as a linked file it would be smaller, cached and reusable.
Where does the MIME type in the data URL come from?
From the file itself. The data URL begins 'data:' followed by the image's MIME type — image/png, image/jpeg, image/webp, image/gif, image/svg+xml — then ';base64,' and the encoded data. The browser reports the type of the file you select, and this tool uses that reported type unchanged, because a wrong type in the prefix can stop the image rendering at all. If you convert the image to another format first, re-run it here so the prefix matches.
Is my image uploaded for conversion?
No. The file is read and encoded by your own browser using its built-in FileReader; nothing is sent to a server or stored. That is just as well — a tool whose entire output is a text copy of your image would be a strange place to upload anything private. Load the page, go offline, and the converter still works.
Related tools
Encoding maths and worked examples last verified: 24 November 2026. Everything is calculated in your browser — nothing you type is sent anywhere.