- Home
- All tools
- Convert & optimize
- Image to Base64
Convert an image to Base64
Embed small images directly in HTML, CSS, JSON or emails as a Base64 data URI — or turn a Base64 string back into an image file.
- 1Add image or paste code
- 2Pick the output
- 3Copy or download
Drop your image here
Base64 is best for small images like icons and logos (under about 10 KB).
Paste a data URI anywhere a normal image URL would go.
Done
Your output is ready.
How to convert an image to Base64
What is Base64 and when should I use it?
Base64 turns binary data, like an image, into plain text made of letters, numbers, + and /. A data URI wraps that text with the file type (for example data:image/png;base64,…) so a browser can display it without downloading a separate file.
It's handy for small images: icons in a stylesheet, a logo in an HTML email signature, placeholder images, images inside JSON or API payloads, and single-file HTML pages. Because the image travels inside the code, there's one fewer network request.
When not to use Base64
Base64 makes files about 33% larger, and an embedded image can't be cached separately by the browser — it's downloaded again with every copy of the page or stylesheet. For photos and anything over roughly 10 KB, a normal image file is faster. If your image is large, compress it first or use a regular file instead.
Using the output
- HTML:
<img src="data:image/png;base64,…" alt="…"> - CSS:
background-image: url("data:image/png;base64,…"); - Markdown:
(support varies by platform)
Frequently asked questions
Is my image uploaded?
No. Encoding and decoding happen entirely in your browser.
Why is the Base64 text so long?
Every 3 bytes of the image become 4 characters of text, so a 30 KB image becomes about 40,000 characters. That's normal — and a sign the image may be too large to embed.
Can I use Base64 images in emails?
Some email apps display them, but Gmail and several others block data-URI images. For reliable email images, host the image and link to it.
My decoded image won't show — why?
Make sure you pasted the complete string with nothing cut off, and that it really is an image. Line breaks and spaces are removed automatically.