Toolstia / Image to Base64 converter
Convert an image to Base64
Drop in an image and get its Base64 text, ready to paste into HTML, CSS or JSON. Choose a full data URI, the plain Base64 text, a CSS background-image rule, or an HTML img tag. Your image is not uploaded.
Drop an image here, or click to choose
JPG, PNG, WebP, GIF or SVG, up to 8 MB. Nothing is uploaded.
How it works
- Drop in your image.
- Choose the output format.
- Copy the result or download it as a text file.
What Base64 is for
Base64 writes a file as plain text. A data URI such as data:image/png;base64,... lets a small picture live inside your HTML or CSS, with no separate file to load.
When it helps
It suits tiny icons, email templates and single-file pages. It adds about one third to the size, and the browser cannot cache it separately, so it is a poor choice for large photos.
The original file is encoded
Your image is encoded exactly as it is, not re-compressed. If the result is too long, shrink the picture first with the image compressor.
The other direction
To turn Base64 text back into readable text, use the Base64 encoder and decoder.
Questions
Is my image uploaded?
No. It is read inside your browser.
Is there a size limit?
Images up to 8 MB are accepted, but anything over a few kilobytes makes very long text.
Does it work with SVG?
Yes. The SVG is encoded as it is.
Which output should I use?
Data URI for an img src, CSS background-image for styles, and Base64 text only if your code adds the prefix itself.