How to use the Image to Base64 tool
- Select the File field. The picker is filtered to image files such as PNG, JPEG, GIF, WebP and SVG.
- Choose the image, then select Encode file.
- Copy the Base64 from the Result box with the Copy button.
- Or select Download to save the string as a text file named after your image with .base64 appended.
- To use it as a data URL, put data:image/png;base64, or the prefix for your format in front of the string.
What the image to Base64 encoder does and does not do
The tool reads the image file byte for byte and encodes it with standard, padded Base64. It does not decode pixels, so nothing is resized, recompressed or converted. A 40 KB JPEG yields the Base64 of that same 40 KB JPEG, Exif metadata included. If the photo carries GPS coordinates, they are in the string too.
The Result is the bare Base64. The data: prefix is not added, because the same string is also used in places that do not want it, such as JSON request bodies for vision and OCR APIs.
Worked example: from GIF file to data URL
A 1 by 1 transparent GIF of 42 bytes, saved as dot.gif, encodes to the 56 characters below. To display it without a separate request, prepend the scheme, the media type and the base64 marker, and use the whole value as an image source.
dot.gif (42 bytes)
R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
As a data URL:
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
In HTML:
<img src="data:image/gif;base64,R0lGODlh..." alt="">Media types for the data URL prefix
The prefix must name the real format of the file. Browsers use it to choose a decoder. For CSS backgrounds, the CSS Data URI Converter on this site writes the complete background-image declaration for PNG, JPEG, GIF and WebP files.
- PNG: data:image/png;base64,
- JPEG: data:image/jpeg;base64,
- GIF: data:image/gif;base64,
- WebP: data:image/webp;base64,
- SVG: data:image/svg+xml;base64,
- AVIF: data:image/avif;base64,
When inlining an image is worth it
A Base64 image saves one HTTP request and costs about 33% more bytes. It also cannot be cached on its own: it is downloaded again with every copy of the HTML or CSS that contains it. That trade works for small assets such as icons, placeholders and tiny logos, and for single-file deliverables such as HTML reports.
It works poorly for photos and large graphics. Long strings bloat the document and delay rendering. A page with a strict Content Security Policy must allow data: in img-src before inline images appear, and some email clients refuse to show data URL images at all. SVG is often smaller when inlined as URL-encoded text than as Base64.
Frequently asked questions
Is my image uploaded when I convert it to Base64?
No. The browser reads the file from disk and encodes it in the page. Private photos, scans and unreleased designs never reach a server.
Why is there no data:image prefix in the result?
The tool outputs raw Base64 so it fits any target. Add the prefix yourself when you need a data URL: data:, then the media type such as image/png, then ;base64, and finally the string.
Does encoding change image quality?
No. Base64 is a lossless representation of the file's bytes. Decoding the string gives back the identical file, with the same dimensions, compression and metadata.
What is the largest image I can encode?
20 MiB. Larger files are rejected with Choose a file up to 20 MiB. An image that size produces close to 28 million characters, far more than is sensible to inline in a web page.
Can I encode a file that is not an image?
The picker suggests image files, but the encoder itself does not inspect the content. If your system lets you pick another file type, it is encoded the same way. File to Base64 is the page meant for that.
How do I convert the Base64 back to an image?
Paste it into Base64 to Image. That tool detects PNG, JPEG, GIF and WebP from the decoded bytes, shows a preview and saves the file with the correct extension.