Loading Image to Base64 Converter...

How to Convert an Image to Base64

Step 1

Pick Your Image

Click the "Upload" button or drag the file onto the left panel. Any common web image works, from a PNG screenshot to an SVG logo or a favicon.ico.

•
Recognised formats: PNG, JPEG, GIF, WebP, BMP, ICO/CUR, SVG, TIFF and AVIF (HEIC is turned into a JPEG first)
•
Size limit: up to 10 MB per file
•
Try the sample: "Sample" loads a small 32×32 PNG so you can see the output first
•
Stays on your device: the file is read by your browser and is not uploaded or kept
Step 2

Check the Format and the Output

Encoding starts as soon as the file has been read. The Base64 string fills the editor on the right, and the left panel shows a preview, the file size and the format taken from the file's own header.

•
Wrong extension? A PNG saved as .jpg is still encoded exactly, and a note tells you to start the data URI with data:image/png;base64,
•
Not an image? Text files, PDFs and archives are refused with a message, even when they carry an image name
•
Bare Base64: the output has no data URI prefix, so you add the one you need
•
TIFF preview: most browsers can't draw TIFF, so the preview may stay empty, but the string is still the complete file
Step 3

Copy or Download the String

"Copy" puts the string on your clipboard and "Download" saves it as a .txt file named after the image. Both hold exactly what the editor shows. "Reverse" opens Base64 to Image in a new tab if you want to check the round trip.

•
HTML: <img src="data:image/png;base64,..." alt="...">
•
APIs: send the bare string in a JSON field when an endpoint expects an image as Base64

Data URI Prefixes and How Each Format Starts

The first characters of a Base64 image give its format away, which helps when you find a string in a database or a log and wonder what it is.

FormatData URI prefixBase64 starts with
PNGdata:image/png;base64,iVBORw0KGgo
JPEGdata:image/jpeg;base64,/9j/
GIFdata:image/gif;base64,R0lGOD
WebPdata:image/webp;base64,UklGR
SVGdata:image/svg+xml;base64,PHN2Zy or PD94bWwg
ICOdata:image/x-icon;base64,AAABAA
BMPdata:image/bmp;base64,Qk

Should You Inline Images as Base64?

Inlining saves one request, and that is about all it saves. Base64 makes the image roughly 33% bigger, and the browser can no longer cache it separately: the bytes travel again with every page or stylesheet that contains them.

It pays off for small, single-use pictures such as a loading spinner, a tiny SVG icon in a stylesheet, an image inside a self-contained HTML report, or an image an API insists on receiving as text. For photos, hero images and anything shared across pages, a regular image file is faster.

Frequently Asked Questions

Which image formats can I encode here?

PNG, JPEG, GIF, WebP, BMP, ICO (and CUR cursors), SVG, TIFF and AVIF. The page looks at the first bytes of the file to work out the format, so the label you see next to the file size is what the file really is, not what its name claims. HEIC photos are the one exception: they are turned into a JPEG first, so you get the Base64 of that JPEG rather than of the original HEIC file.

What is the difference between a data URI and plain Base64?

Plain Base64 is just the encoded characters, which is what the output panel shows and what Copy and Download give you. A data URI puts a short header in front so a browser knows what it is looking at: data:image/png;base64, followed by the string. Use the data URI in an img src or a CSS url(), and the plain string when an API or a JSON field asks for Base64 on its own.

How do I know which data URI prefix to use?

Match it to the format shown next to the file size: data:image/png;base64, for PNG, data:image/jpeg;base64, for JPEG, data:image/gif;base64, for GIF, data:image/webp;base64, for WebP and data:image/svg+xml;base64, for SVG. If a file has the wrong extension, say a PNG saved as photo.jpg, the page encodes it as it is and shows a note with the prefix that fits the real format.

When is a Base64 image a bad idea?

When the image is big or used on more than one page. The string is about a third larger than the file, it has to be downloaded again with every HTML or CSS file it sits in, and the browser can't cache it on its own. A 2 KB icon or a 1x1 tracking pixel is a fine candidate. A 400 KB product photo is better served as a normal file.

Will the decoded image be identical to my file?

Yes, for every format except HEIC. The page encodes the file byte for byte, with no resizing, re-compression or metadata stripping, so transparency, animation frames, ICO sizes and any EXIF data stay inside the string. Paste it into Base64 to Image and you get back the same file you uploaded.

What happens if I upload something that is not an image?

A text file, PDF, ZIP or GZIP archive is refused with a short message that says what the file looks like, even if it was renamed to .png. An empty file is reported as empty. For files that really aren't images, File to Base64 encodes anything.

How large can the image be?

Up to 10 MB. Keep in mind that a 10 MB image becomes roughly 13.3 MB of text, which is far too much to paste into HTML or a JSON request comfortably.

Is my image uploaded anywhere?

No. Your browser reads the file and builds the Base64 string on your own machine; the image is not sent to a server and nothing is kept, so a reload starts with an empty panel. SVG files are shown in the preview as a plain image, so any script inside them does not run.

To turn a string back into a picture, use Base64 to Image. There are also pages written around a single format, such as PNG to Base64, JPG to Base64 and SVG to Base64, and File to Base64 handles files that aren't images.