Loading Base64 to Image Converter...

How to Convert Base64 to an Image

Images turn up as Base64 all the time: an avatar field in a JSON API response, a logo inlined into an HTML email, a background in a CSS file, a screenshot stored in a database column. Usually you just want to see the picture, or save it as a normal file, without first working out which format it is. That is what this page does.

Step 1

Paste the Base64 string

Paste the string into the input panel: a bare Base64 value from a JSON response, or a full data: URI copied from HTML or CSS. Line breaks, surrounding quotes and URL-safe characters (- and _) are fine. You can also upload a .txt file holding the string.

•
Copied from JSON? Paste the whole quoted value if you like; the quotes are removed before decoding.
•
About the Sample button: it loads a small 32 by 32 PNG so you can see what a decoded result looks like.

How the start of the string gives the format away

iVBORw0KGgo...   # PNG
/9j/4AAQSkZJRg...# JPEG
R0lGODlh...      # GIF
UklGR...         # WebP (RIFF)
PHN2Zy...        # SVG (<svg as text)
Step 2

Check the format and preview

The string is decoded a moment after you paste. The Format line shows what the bytes really are, and the preview shows the picture when your browser can draw that format. A typo in the string is reported with its line and column.

•
The bytes decide the format: a JPEG pasted with a data:image/png prefix is still shown as JPEG and saved as .jpeg.
•
Cut-off strings: if the length no longer fits Base64, the page says the string looks cut off. If it still fits, you may get the top part of the picture only, so compare the length with the original.
•
Not an image: text, PDFs and archives are named in the error. Base64 to File saves those.
Step 3

Download the image

Click Download to save the decoded bytes with the extension of the detected format. On larger screens you can type a file name first; the extension is added for you.

•
Same file as before encoding: the download has the original resolution, transparency and metadata, because nothing is re-compressed.
•
Next string: click Clear and paste the next one.
•
Going the other way: Image to Base64 turns an image file into a Base64 string or data URI.

Why images end up as Base64

Image files are binary, and plenty of places only carry text: JSON bodies, HTML attributes, CSS rules, environment variables, CSV exports. Base64 spells any bytes with 64 safe characters, at the cost of making the data about a third larger, so it is the usual way to squeeze a PNG, JPEG or WebP into one of those.

Decoding simply reverses that, giving back the original bytes. If you are reading a JSON response that holds images next to other fields, JSON to Table lays the rest of the data out so you can find the field you need.

Frequently Asked Questions

I don’t know what format my Base64 image is. Does that matter?

No. After decoding, the page looks at the first bytes of the file, where every image format leaves a fixed signature, and names the format it finds. The download gets the matching extension. You can often tell by eye too: PNG strings start with iVBOR, JPEG with /9j/, GIF with R0lGOD and WebP with UklGR.

Which formats does it recognise?

PNG, JPEG, GIF, WebP, BMP, TIFF, ICO and CUR icons, AVIF, HEIC and SVG. Chrome, Edge and Firefox can preview most of these. TIFF and HEIC usually have no preview in those browsers; the page says so, and the download is still the complete file.

The data URI says image/png, but the page says JPEG. Which is right?

The page is. The MIME type in a data: URI is just a label someone typed, and it is wrong more often than you would think, for example when a JPEG gets stored under a hard-coded data:image/png prefix. The page goes by what the bytes say, so the file you download opens in any viewer.

Does decoding change the image in any way?

No. Base64 is only a text wrapper around the original bytes, so decoding gives back exactly what was encoded: same resolution, same colours, same transparency, same metadata. Nothing is re-compressed or converted, which also means a WebP stays a WebP. To change the format you need an image editor.

What if the string is not an image at all?

You get an error that says what the data looks like instead, for example plain text, a PDF or a ZIP archive. For those, Base64 to File saves any kind of data with the right extension.

Is it safe to paste an SVG that someone sent me?

Yes. The preview loads the decoded file as an image, and browsers never run scripts inside an SVG shown that way. The SVG file you download is unchanged, though, so be careful if you later open it directly in a browser tab.

Is my image uploaded anywhere?

No. Decoding, the preview and the download all happen in your browser. Nothing is sent to our server and nothing is kept, so the editor is empty again after a reload. Very large strings are only limited by your browser’s memory.

Related pages: Base64 to File · Base64 to PNG · Base64 to JPG · Image to Base64