What a Base64 image is
Base64 is a way of writing binary data, such as the bytes of a PNG file, using only 64 ordinary text characters. Turned into a data URI, an image becomes a line of text that starts with data:image/png;base64, and can be pasted straight into HTML, CSS, JSON or an e-mail template, with no separate image file to host. This tool reads your image, shows a preview and gives you the data URI ready to copy, or a complete CSS background rule.
How to convert an image to Base64
- Upload the image you want to encode.
- See the preview and the generated Base64 string.
- Click Copy Base64 for the raw data URI.
- Or click Copy as CSS background to paste straight into a stylesheet.
Features
- Instant Base64 data URI generation.
- One-click copy as raw string or CSS rule.
- Live preview of the encoded image.
- Runs locally โ nothing is uploaded.
- Free and works with any image format.
How to use the result
| Where | Paste it like this |
|---|---|
| HTML | <img src="data:image/png;base64,iVBORw0..." alt="Logo"> |
| CSS | .icon { background-image: url("data:image/svg+xml;base64,PHN2..."); } |
| JSON or an API request | Use the part after the comma if the API asks for raw Base64 |
Why the text is longer than the file
Every 3 bytes of the image become 4 characters of text, so Base64 is about 33% larger than the original. A 6 KB icon becomes roughly 8 KB of text; a 600 KB photo becomes 800 KB of text sitting inside your HTML or CSS file.
When Base64 is a good idea, and when it is not
- Good: small icons and logos under a few KB, e-mail templates where linked images are blocked, single-file HTML demos, and test data.
- Not good: photos and large images. They make your page heavier, the browser cannot cache the image on its own, and the same picture is downloaded again with every page that contains it.
Shrink an image first with Image Compressor or Image Resizer to keep the string short. To turn a hex colour value into CSS instead of a picture, see the Color Picker.
Is Base64 encryption?
No. Base64 only changes how the data is written; anyone can turn it back into the picture. Do not use it to hide private images.
How long will the string be?
| Image | File size | Base64 text | Good idea? |
|---|---|---|---|
| 16 × 16 favicon PNG | about 0.5 KB | about 0.7 KB | Yes |
| Simple logo PNG | about 6 KB | about 8 KB | Yes, for e-mail templates |
| Product photo JPG | about 150 KB | about 200 KB | No, link the file instead |
| Phone photo JPG | about 3 MB | about 4 MB | No |
For icons made of simple shapes, an SVG file is often smaller still, and SVG can be placed in HTML as code without Base64 at all.
Your privacy
The image is encoded by your own browser and never uploaded. The Base64 text exists only on your screen until you copy it.
Frequently asked questions
What is a Base64 data URI used for?
To put an image directly inside HTML, CSS, JSON or an e-mail template as text, so no separate image file has to be hosted or requested.
How much bigger does Base64 make an image?
About one third bigger, because every 3 bytes are written as 4 text characters.
Should I use Base64 for large photos?
No. Large images make the page heavier and cannot be cached separately. Use Base64 only for small icons and logos.
Can I use the result in CSS?
Yes. The CSS button copies a complete background-image rule you can paste into your stylesheet.
Is Base64 a way to encrypt an image?
No. It is only a different way of writing the same data, and anyone can decode it back to the picture.
Is my image uploaded?
No. Encoding happens entirely in your browser.