Home / Tools / Image to Base64
Image to Base64 Converter
Encode a JPG, PNG, WebP, GIF or SVG as Base64 text, ready to paste into HTML, CSS or JSON. You can also paste Base64 back in to preview and download the image. Everything runs in your browser.
Image to Base64
How to use the Image to Base64
- Choose an image.
- Pick an output format: data URI, plain Base64, an HTML img tag or a CSS background-image rule.
- Press Copy to clipboard, or download the text file.
- To reverse it, paste Base64 into the box at the bottom and press Preview image.
What is a Base64 data URI?
Base64 turns binary data, such as an image, into plain text. A data URI adds a short label in front, for example data:image/png;base64,, so a browser can show the image directly from text with no separate file. That is useful for small icons in emails, single-file HTML pages and API requests that only accept text.
When Base64 is a good idea, and when it is not
- Good: tiny images such as icons and logos under about 100 KB, single-file demos, email templates, test data.
- Not good: large photos. Base64 makes the data about 33% bigger, the browser cannot cache the image separately from the page, and big strings slow down your HTML or CSS.
For large images, shrink them first with the Image Compressor or keep them as normal files.
The four output formats
- Data URI: the full string you can use as an image source.
- Base64 string only: without the label, for APIs and databases.
- HTML img tag: a ready-made tag with width and height. Replace the alt text with a real description.
- CSS background-image: a rule you can paste into a stylesheet.
Privacy
Your image is read by your browser and turned into text on your device. It is not sent to a server.
Frequently asked questions
Why is the Base64 text larger than my image?
Base64 represents every 3 bytes of data with 4 characters, so the text is about one third bigger than the file.
Can I use the data URI as an image source?
Yes. Paste it into the src attribute of an img tag, or into a CSS url().
How do I turn Base64 back into an image?
Paste the Base64 text or data URI into the box under Base64 back to image, press Preview image, then download.
Is it safe to paste private images?
The conversion happens in your browser and nothing is uploaded. Be careful about where you paste the result afterwards.
Which formats are supported?
JPG, PNG, WebP, GIF and SVG up to 25 MB.
Large image? Compress it before encoding to keep the Base64 short.
Browse all free tools