Loading Base64 to Image Converter...

How to Convert Base64 to a PNG Image

PNGs end up as Base64 text all the time: icons inlined into CSS, logos in HTML email, screenshots returned by test runners, images drawn on a canvas and exported with toDataURL(), avatars stored in a JSON field. Paste the string below to see the picture and get the real file back.

Step 1

Paste the Base64 string

Paste the string into the input panel, or upload a .txt file that contains it. A data:image/png;base64, prefix, line breaks and URL-safe Base64 are all accepted.

•
Spot a PNG quickly: a Base64 PNG begins with iVBORw0KGgo, which is the fixed PNG signature written in Base64.
•
Copied from CSS or HTML: you can keep the data:image/png;base64, part; it is stripped before decoding. Leave out the surrounding url(...) or quotes.
•
Just want to try it: the Sample button loads a small 32 by 32 PNG.
Step 2

Check the preview

A moment after you paste, the string is decoded and the PNG appears in the preview. The Format line tells you what the header says the file really is. If a character is not valid Base64, the error names its line and column.

•
Transparency: see-through pixels show the page background in the preview, and they stay see-through in the download.
•
A different format: if the header says JPEG, GIF or WebP, the page tells you so instead of pretending it is a PNG.
•
Not an image after all: if the bytes turn out to be text, a PDF or an archive, you get a message instead of a broken picture. Base64 to File can save any kind of data.

What is inside a PNG

An eight-byte signature, then a series of chunks: IHDR with the width, height and colour type, IDAT with the compressed pixels, and IEND to close the file. Optional chunks carry things like the transparency of a palette image, gamma or a text comment. The PNG specification describes every chunk, and Base64 itself is defined in RFC 4648.

Step 3

Download the PNG

Click Download to save the decoded bytes as a .png file. On wider screens you can type your own file name before saving.

•
Same file as before: the download is byte for byte what was encoded, so it opens in any image viewer, editor or design tool that took the original.
•
Next one: click Clear and paste the next string.
•
Going the other way: PNG to Base64 turns a .png file into a string you can paste into CSS or HTML.

Frequently Asked Questions

How can I tell that a Base64 string is a PNG?

Every PNG file opens with the same eight bytes, and in Base64 those come out as iVBORw0KGgo at the very start of the string. If you see that, it is a PNG. You do not have to check by hand, though: the page reads the decoded header and shows the format it found above the preview.

Will the transparent parts survive?

Yes. The page does not redraw or re-save the image. The file you download is exactly the bytes that were encoded, so the alpha channel, colour depth and any text chunks inside the PNG come back unchanged. In the preview you will see the page background through the see-through pixels.

I copied a data:image/png;base64 URI out of CSS or an email. Can I paste it as is?

Yes. The data:image/png;base64, part is stripped before decoding, and line breaks are ignored, so a string copied from a stylesheet, an HTML img tag or the source of an email works. Just leave out the surrounding url(...) or quotes.

Does this work with the output of canvas.toDataURL() or a screenshot tool?

It does. canvas.toDataURL() gives a PNG data URI unless you ask for another type, and many screenshot and testing tools (Puppeteer, Playwright, Selenium) hand back screenshots as Base64 PNG text. Paste the string here to look at the picture and save it as a real .png file.

Is the image re-compressed or resized?

No. Base64 is only a text wrapper around the file, so decoding gives back the original file byte for byte. Nothing is resized, re-compressed or converted. The decoded file is about three quarters the length of the Base64 text, because Base64 uses four characters for every three bytes.

It says JPEG or GIF instead of PNG. What happened?

The page names the format the bytes really are and saves the download with the matching extension, so a JPEG is saved as .jpeg even on this page. Nothing is converted between formats. If the string is not an image at all, for example text or a PDF, you get a message saying so, and Base64 to File can save that kind of data.

Is my Base64 sent to your server?

No. Decoding happens in JavaScript inside your browser, and the preview and the download are built on your own machine. Nothing is uploaded and nothing is kept, so a reload starts with an empty editor.

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