How to use the Base64 to PNG tool
- Paste the string into the Base64 or Base64 data URL box, or select Example to load and decode a tiny 2 by 2 pixel PNG.
- Select Decode file to decode the string and test its signature.
- Look at the Result box for the size and the type image/png, and at the preview below it for the picture.
- Select Download to save the image as decoded.png.
How the Base64 to PNG check works
Every PNG begins with the same eight bytes: 89 50 4E 47 0D 0A 1A 0A. The PNG specification chose them on purpose. The first byte has its high bit set to expose channels that strip data to 7 bits. The letters PNG follow. The CR LF pair and the final LF reveal transfers that rewrite line endings.
After decoding, this tool compares the first eight bytes with that signature. A match means the result is offered as image/png. Anything else, even a valid JPEG or GIF, is refused with The Base64 does not contain a PNG file.
Reading a PNG straight from its Base64
The fixed signature gives Base64 PNG data a fixed opening too. The eight signature bytes are followed by the IHDR chunk, whose length field and name never change. As a result every PNG narrower than 65,536 pixels starts with the same 24 characters: iVBORw0KGgoAAAANSUhEUgAA.
The Example value, shown below on two lines, decodes to 79 bytes. Inside are three chunks: IHDR with 13 bytes that declare a 2 by 2 image with 8-bit RGB color, IDAT with 22 bytes of zlib-compressed pixel rows, and an empty IEND that closes the file.
iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAFklEQVR42mP8v4CfgYGB
iYGBgYGBAQAVQgGy9omCFwAAAABJRU5ErkJggg==
Result: 79 bytes · image/png
File: decoded.pngInput the PNG decoder accepts
The input box is forgiving about packaging. It does not accept escaped text: remove JSON escapes (a backslash in front of each slash) and percent-encoding such as %2B before pasting, or the decoder answers Enter valid Base64 or Base64URL data.
- A bare Base64 string, with or without = padding.
- A data URL. Text up to the base64, marker is cut off, and the declared type is not trusted: a PNG labeled data:image/jpeg still decodes as PNG.
- Base64URL, where - and _ replace + and /. The tool switches alphabets when it sees either character.
- Wrapped text. Spaces, tabs and line breaks from email or PEM style formatting are removed.
PNG, JPG or the general image tool
Use this page when the output must be a PNG, such as an icon, a screenshot or a QR code. It works as a format assertion: if an API contract promises PNG and the bytes are something else, you get an error instead of a mislabeled file. Base64 to JPG applies the same idea to JPEG data. Base64 to Image accepts PNG, JPEG, GIF and WebP and names the download after whatever it detects.
None of these tools re-encode pixels. A JPEG is never turned into a PNG; the bytes are written out exactly as decoded.
Frequently asked questions
Is the image uploaded when I convert Base64 to PNG?
No. The string is decoded by script in the page and the preview is drawn from a local object URL. No request carries your image data to a server.
Why do I get The Base64 does not contain a PNG file?
The decoded bytes do not start with the PNG signature. Common reasons are that the data is JPEG (it begins with /9j/), the string lost its first characters during copying, or the value was Base64 encoded twice.
Does the preview prove the PNG is complete?
No. Only the first eight bytes are verified. A file that was cut off later passes the check, and the browser may draw part of the picture or a broken image icon.
Does decoding keep transparency and color profiles?
Yes. The decoded bytes are written without changes, so the alpha channel, ICC profile chunks and text metadata remain exactly as encoded.
Can I convert a data URL from a canvas?
Yes. The string returned by canvas.toDataURL() starts with data:image/png;base64, by default. Paste the whole value. The prefix is removed and the rest is decoded as a PNG.