Image to Base64 Converter
Drop an image and get its Base64 Data URI — plus the HTML, CSS and Markdown snippets that use it, and an honest readout of how much bigger the encoded version is. Going the other way? The decoder below turns a Data URI back into a preview and a downloadable file. Everything runs in your browser; your image is never uploaded.
Drop an image here or browse files
JPG · PNG · WebP · GIF · SVG — converted locally in your browser, never uploaded
Convert an image above, or decode a Data URI below.
🔒 Your image is encoded in this page’s memory only. Nothing is uploaded, stored or sent anywhere — close the tab and it is gone.
How it works
- 1 Add an image
Drop a JPG, PNG, WebP, GIF or SVG. Its size and dimensions are shown before you commit to anything.
- 2 Keep or re-encode
Keep the original bytes, or re-encode to PNG, JPEG or WebP first when a smaller payload matters more.
- 3 Check the size
The stats show the exact character count and overhead — and warn you when inlining stops being a good idea.
- 4 Copy & paste
Take the raw Data URI or the ready-made snippet for HTML, CSS or Markdown.
Specifications
| Input | JPG, PNG, WebP, GIF or SVG image, dropped or browsed — any size your device can hold |
|---|---|
| Output | Base64 Data URI, plus copy-ready HTML <img>, CSS background and Markdown snippets |
| Re-encoding | Optional conversion to PNG, JPEG (quality 0.92, transparency flattened to white) or WebP (quality 0.92) before encoding |
| Size honesty | Exact character count, original file size and the encoded overhead percentage; a warning appears past 1,000,000 characters |
| Decoder | Paste a Data URI to validate it, preview the image, see its dimensions and decoded size, and download it as a file |
| Rendering | Entirely in your browser — FileReader and canvas, nothing uploaded |
| Cost | Free, unlimited, no watermark, no account |
Good to know
- Base64 is a transport format, not compression: it makes an image about a third bigger, never smaller. If the goal is a lighter page, shrink the image itself first — the Image Compressor does that in the same browser-local way.
- Inlined images cannot be cached on their own: every page carrying the Data URI re-downloads those bytes with the HTML. That is the real cost behind the “one less request” saving, and why big inlines backfire.
- HTML email is the honourable exception: many email clients block remote images but render Data URIs, so small signature logos and icons are a legitimate use — keep them tiny.
- SVG files are already text: an SVG can often be inlined as-is or URL-encoded instead of Base64, which stays readable and can come out smaller. Base64 still works here when a tool insists on it.
Frequently asked questions
Why is the Base64 version about 33% bigger than the image file?
Base64 packs every 3 bytes of image data into 4 text characters, so the encoded form is always roughly 4/3 the size of the binary — before any other overhead. The stats under the output box show the exact character count and percentage for your image, so you can judge the trade with real numbers instead of folklore.
When is inlining an image as Base64 actually a good idea?
For genuinely small images: icons, tiny logos, email signatures and single-file documents where a separate request costs more than the extra bytes. It also helps when the image must travel inside a format that cannot reference files — a JSON payload, a CSS file, an HTML email. For photographs and anything over roughly 50–100 KB, a normal hosted file with caching almost always loads faster.
Does converting to PNG, JPEG or WebP change the image?
Only if you ask it to. The default keeps the original bytes untouched — the Data URI wraps the exact file you dropped. Choosing PNG, JPEG or WebP re-encodes the pixels on a canvas at quality 0.92: JPEG drops transparency onto white and usually shrinks photos, PNG stays lossless, WebP usually lands smallest while keeping transparency. The stats line tells you which mode produced the result.
Can this tool really decode a Data URI back into an image?
Yes — that is the second box on this page. Paste any data:image URI and it validates the header, previews the picture, estimates the decoded byte size from the Base64 length, and offers the image back as a downloadable file with the right extension. Handy when a Data URI is all you have — buried in a stylesheet, a JSON export or an email.
Is my image uploaded so the server can encode it?
No. Encoding happens with your browser’s own FileReader and canvas APIs; the file never leaves your device. That is also why there is no file-size limit imposed by an upload endpoint — the practical limit is your device’s memory, and the tool warns you when a result gets unwieldy.
Why does my Data URI start with data:image/png when my file was a JPG?
Because the prefix describes the bytes actually inside the URI, not the file you started with. If you re-encode to PNG, the payload is PNG data and the prefix follows it. Keep the default “original format” mode when the exact original encoding matters — for example when a system checks the file hash.
Next steps
More free tools
Color Picker from Image · QR Code Generator · Image Compressor · Image to SVG · OG Image Generator · Code to Image