Image to Base64 Converter
Sometimes an image needs to live inside the code itself — a tiny icon in a stylesheet, a logo in an HTML email, a test fixture in a demo page. A Base64 data URI embeds the whole image as text, so no separate file is needed.
Upload an image and get its Base64 data URI instantly, ready to paste into HTML or CSS — all in your browser, nothing uploaded.
Base64 Output
How It Works
Base64 is a way of writing binary data — like the bytes of an image — using only 64 safe text characters (A–Z, a–z, 0–9, + and /). A data URI wraps that text with a prefix saying what it is: data:image/png;base64, followed by the encoded image. Browsers understand data URIs anywhere a URL works — in an <img> tag, a CSS background, even the address bar.
Encoding costs about 33% extra size: every 3 bytes of image become 4 characters of text. That is why data URIs suit small images — icons, logos, tiny patterns — and not large photos. A 69-byte 1×1 red PNG becomes a 114-character data URI: the 22-character prefix plus 92 characters of Base64. A 2 MB photo would become roughly 2.7 MB of text, which is almost never worth embedding.
Worked Example
The sample image is a single red pixel saved as PNG — 69 bytes. Its data URI is data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAADElEQVR4nGP4z8AAAAMBAQDJ/pLvAAAAAElFTkSuQmCC — 114 characters in total. Click "Try the sample image" above to see the tool produce exactly that output.
How to Use This Tool
Choose an image, pick an output format, and click Convert to Base64. The encoded output appears below with its size and a copy button.
- Choose an image. Any format your browser can open. Small images work best — data URIs grow about 33% larger than the file.
- Pick an output format. Data URI only gives you the raw string; HTML wraps it in an
<img>tag; CSS wraps it in abackground-image: url(...)rule. - Copy the output. Click Copy Output, or click inside the text area to select everything, then paste it into your code.
The preview under the output shows the image decoded back from the data URI, so you can confirm the encoding worked before you paste it anywhere.
Tips and Practical Advice
- Keep embedded images small. Under about 10 KB is the sweet spot. Bigger images bloat your HTML or CSS and cannot be cached separately by the browser. Cropping away the edges you do not need is the fastest way to shrink one — an image cropper cuts the frame before you embed it.
- Use it for icons and logos. A small logo embedded in an HTML email always displays, even when the reader's email client blocks remote images. If the logo is in the wrong format, convert it first — an image converter switches between PNG, JPEG and WebP.
- Prefer real files for photos. A photo as a data URI is a third larger than the file and must download again with every page. Link to the file instead.
- Watch out for SVGs. SVG files are already text, so Base64-encoding them is usually unnecessary — you can often paste the SVG code directly.
When to Embed an Image — and When to Link It
Base64 is an encoding, not a compression method and not encryption. It rewrites binary bytes using only 64 text characters — A–Z, a–z, 0–9, + and / — so that binary data can travel through systems built for text, like HTML, CSS and JSON. Because three bytes (24 bits) map exactly onto four 6-bit characters, the output is always about a third larger than the input; when the input length is not a multiple of three, = signs pad the end. And because the mapping is public and reversible, anyone can decode Base64 instantly — it hides nothing, so it must never be used for passwords, keys or anything private.
The size maths is exact, so you can plan for it. A 3,000-byte icon becomes 4,000 Base64 characters, plus the 22-character data:image/png;base64, prefix — 4,022 characters in total, a 34.1% overhead. A 12,000-byte logo becomes 16,022 characters, a 33.5% overhead. The percentage shrinks slightly as the file grows, because the prefix is a fixed cost — but the underlying 33% encoding overhead never goes away. A 1 MB photo would become roughly 1.33 MB of text, which is why photos are almost never embedded.
Embedding wins in three situations. The first is HTML email: many email clients block remote images by default, but an embedded logo always displays. The second is a single-file page — a demo, a test page or an offline file — where there is no server to host the image. The third is a tiny icon in a stylesheet: embedding it saves the browser a separate request for the file, though with HTTP/2 that saving is smaller than it used to be. In all three cases the image is small, it must always load, and it cannot break because a file was moved or deleted.
Linking wins everywhere else. A linked image is downloaded once and cached by the browser, then reused on every page that references it; an embedded copy is downloaded again with every page that contains it, and it bloats the HTML or CSS file itself. As a rule of thumb, keep embedded images under about 10 KB, embed only images that appear on one page, and link everything bigger. If the image you want to embed is too large, shrink it first — cropping away the edges you do not need with the Image Cropper or converting it to a smaller format with the Image Converter cuts the embedded size by the same proportion.
Frequently Asked Questions
What is a Base64 data URI?
A data URI embeds a whole file as text inside a URL: data:image/png;base64, followed by the Base64-encoded bytes. Browsers accept it anywhere a normal image URL works, so the image needs no separate file.
How much bigger is the Base64 version?
About 33% bigger than the original file: every 3 bytes become 4 Base64 characters, plus a short prefix. A 69-byte image becomes a 114-character data URI.
Why would I embed an image instead of linking it?
For small images that must always load — a logo in an HTML email, an icon in a stylesheet, or a demo page with no server. Embedded images cannot break from a moved or deleted file.
Is my image uploaded anywhere?
No. The file is read and encoded locally in your browser with the FileReader API. Nothing leaves your device.
Is Base64 the same as encryption?
No. Base64 is an encoding, not encryption — it only changes how bytes are written as text, and anyone can decode it instantly. It offers zero security, so never use it to hide passwords, keys or private data.
Can I use a data URI as a favicon?
Yes — a data URI works in a link rel="icon" tag, and it suits tiny icons because the favicon then needs no separate file. Keep it small: the roughly 33% Base64 overhead matters little on a tiny icon, but it adds up fast on anything bigger.
Last updated: · Last reviewed: 21 November 2026