Image to Base64
Reads image files and returns them as a Base64 data URI, a raw Base64 string, a ready-made img tag or a CSS background-image declaration. Several files can be encoded at once.
Use the tool
Why this tool exists
Embedding a small image straight in HTML, CSS or JSON saves a request and keeps a single file self-contained. That is useful for email templates, small icons, test fixtures and API payloads that expect a Base64 string. Doing the conversion on the command line works if you remember the right flags.
Choose your images and select the output form. For each file you get a comment with its name and sizes, then the encoded text. Be aware that Base64 makes data about a third larger and cannot be cached on its own, so it only suits small images. The file is read by your browser and the encoded text is created locally, so nothing is uploaded.
How to use it
- Choose one or more image files.
- Pick an output: data URI, raw base64, img tag or CSS background.
- Run it and read the encoded result for each file.
- Copy the text into your HTML, CSS or API request.
Frequently asked questions
When is Base64 a good idea for images?
For tiny images such as icons or placeholders where one fewer request matters, and in places that cannot reference a file, such as some emails and JSON. For large images it is wasteful.
How much bigger does the file get?
About 33 percent, because every three bytes become four characters. The comment above each result lists the original size and the encoded size so you can judge.
What is the difference between a data URI and raw Base64?
A data URI includes the prefix with the media type, such as data:image/png;base64, and can be used directly as a src or url. Raw Base64 is only the encoded characters, which many APIs expect.
Can I convert it back to an image?
Yes. Use the Base64 image viewer to preview an encoded image, or the Base64 decode tool to turn the text back into bytes.