What is a Base64 image (data URI)?
Base64 encodes binary data as plain text, so an image can be embedded directly in HTML, CSS, JSON or email templates as a data URI such as data:image/png;base64,iVBOR…. This avoids an extra file request, which is useful for small icons, logos and placeholders, but the text is about 33% larger than the original file. Add an image to get the data URI, the raw Base64 string, an <img> tag or a CSS background rule, then copy or download it. The conversion happens in your browser.
How to convert an image to Base64
- 1
Add an image (PNG, JPG, SVG, WebP, GIF or another format).
- 2
Choose the output: data URI, Base64, HTML or CSS.
- 3
Copy the code or download it as a text file.
- 4
Paste it into your HTML, stylesheet or JSON.
Key features
Four output formats
Data URI, raw Base64, an HTML <img> tag or a CSS background-image rule.
Correct MIME type
The data URI uses the real format detected from the file, not just its extension.
Size information
See the Base64 length and how much larger it is than the file.
Private
The image is encoded in your browser and never uploaded.
Frequently asked questions
Why is Base64 larger than the image file?
Base64 represents every 3 bytes with 4 text characters, so the encoded text is about 33% larger than the binary file.
When should I use Base64 images?
For very small images such as icons, logos or tiny placeholders, where saving an HTTP request matters. Larger images are better served as normal files that browsers can cache.
How do I use a data URI in HTML?
Put it in the src attribute: <img src="data:image/png;base64,…">. In CSS, use background-image: url("data:image/png;base64,…").
Can I convert SVG to Base64?
Yes. The SVG file is encoded as it is, with the image/svg+xml MIME type.