Developer tool
Image to Base64 Data URI Converter
Free, no sign-up. Runs in your browser; nothing is uploaded.
Image
Drop an image here, or
Images only, up to 5.00 MB. Nothing is uploaded.
Preview
sample.svg (image/svg+xml)
Output
data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI5NiIgaGVpZ2h0PSI5NiIgdmlld0JveD0iMCAwIDk2IDk2Ij48cmVjdCB3aWR0aD0iOTYiIGhlaWdodD0iOTYiIHJ4PSIxOCIgZmlsbD0iIzRmNDZlNSIvPjxjaXJjbGUgY3g9IjQ4IiBjeT0iNDQiIHI9IjIyIiBmaWxsPSIjZmZmIi8+PHBhdGggZD0iTTMwIDc0aDM2IiBzdHJva2U9IiNmZmYiIHN0cm9rZS13aWR0aD0iNiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+PC9zdmc+
How to use the image to base64 data uri converter
Convert an image
- Drop an image on the box or press Choose an image. PNG, JPEG, GIF, WebP, AVIF, SVG and other image types work, up to 5 MB.
- Pick the Format you need: the complete data URI, the base64 text only, a CSS
background-imagerule, an HTML<img>tag or a Markdown image. - Press Copy and paste it into your code.
The preview and the size boxes update at once. The sample is a small SVG so the page is never empty.
Size and overhead
Base64 turns every three bytes into four characters, so the text is about 33 percent larger than the file. The size panel shows the original size, the base64 length, the full data URI and the overhead in percent. Because the data lives inside your HTML or CSS, it cannot be cached separately and it delays the rest of the file while it downloads.
A warning appears when the image is over about 10 KB. For larger images a regular file served with caching and compression is normally the better choice.
When inlining makes sense
- Tiny icons and background textures in critical CSS.
- HTML email templates and single-file reports that must work without extra requests.
- Test fixtures, Markdown notes and demo snippets.
Decode a data URI
Switch to Data URI to image and paste a data URI, a CSS url() value or a bare base64 string. The tool detects the image type, shows a preview and lets you download the file. Anything that is not an image is refused.
Privacy
The file is read with the browser's own file reader and converted on your device. It is never uploaded, so private screenshots and logos stay with you.
Frequently asked questions
What is a data URI?
A data URI puts the file contents inside the URL itself, in the form data:image/png;base64,... Browsers can show it without making a separate request, so it works in HTML, CSS and Markdown.
Why is the result bigger than the image?
Base64 writes every 3 bytes as 4 text characters, so the encoded data is about 33 percent larger, plus a short prefix. Gzip on the server recovers some of that for text files but not all of it.
When should I inline an image?
For tiny assets such as small icons, placeholders and one-off emails, where saving a request matters. Above about 10 KB a normal file with caching is usually faster.
Is it safe to use SVG here?
The preview shows the image through an img tag, which never runs scripts. If you paste an SVG data URI into your own page, keep it in an img or CSS background and do not inject it as HTML.
What is the file size limit?
Files are limited to 5 MB so the browser stays responsive. A clear message appears if you pick something larger or a file that is not an image.