Base64 to Image
Published Updated
Paste a Base64 string or a data URL and get the image back with a preview and a download. The file type is read from the first bytes (PNG, JPEG, GIF, WebP, BMP, ICO, AVIF, SVG or PDF), URL-safe Base64 is accepted, and a cut-off PNG, JPEG, GIF or WebP string is rejected.
What the page does with each input
Results from replaying the page's decode steps in Google Chrome 156 on a 64 x 48 test image:
| Input | Result |
|---|---|
| PNG data URL | decoded.png, 64 x 48 preview, 2,460 bytes |
| JPEG data URL | decoded.jpg, preview, 951 bytes |
| WebP data URL | decoded.webp, preview, 702 bytes |
| Bare PNG string, type left on .bin | decoded.png, detected as PNG, preview |
| The same string with .png picked | decoded.png, preview |
76-character lines, or = removed | Accepted |
URL-safe - and _ | Accepted |
Where the formats come from
A data URL, as RFC 2397 defines it, is data: followed by an optional media type, an optional ;base64 and a comma. The page reads only the Base64 form. The URL-safe alphabet comes from section 5 of RFC 4648, which swaps two characters of the standard one.
Base64 writes 3 bytes as 4 characters, so the 2,460-byte PNG was 3,280 characters long. A 1 MB picture is a string of about 1.33 million characters.
Nine formats decoded in three browsers
Measured with the page's own decoder in Google Chrome 158, Firefox 155 and Playwright's WebKit build (not the Safari app), on 64 x 48 test files made with Pillow 11.3.0 (a 32 x 32 icon) and a small hand-written SVG and PDF, pasted as bare Base64. The type was read from the first bytes every time, and the downloaded file was byte for byte the original.
| Format | Saved as | Bytes | Chrome 158 | Firefox 155 | The WebKit build |
|---|---|---|---|---|---|
| PNG | decoded.png | 272 | Preview | Preview | Preview |
| JPEG | decoded.jpg | 1,275 | Preview | Preview | Preview |
| GIF | decoded.gif | 259 | Preview | Preview | Preview |
| WebP | decoded.webp | 496 | Preview | Preview | Preview |
| BMP | decoded.bmp | 9,270 | Preview | Preview | Preview |
| ICO (32 x 32) | decoded.ico | 700 | Preview | Preview | Preview |
| AVIF | decoded.avif | 409 | Preview | Preview | Preview |
| SVG | decoded.svg | 181 | Preview | Preview | Preview |
| PDF (not a picture) | decoded.pdf | 69 | No preview | No preview | No preview |
Input shapes the decoder takes or refuses
The same runs, with the 64 x 48 PNG unless the row says otherwise. All three browsers gave the same result for every row. A refusal shows the message in the right-hand column and no file.
| Input | Result |
|---|---|
| Spaces and tabs inside the string, or spaces and blank lines around it | decoded.png, the same bytes |
Two extra = at the end | decoded.png |
| A data URL with a line break straight after the comma | decoded.png |
data:;base64, (no media type) before PNG data | decoded.png with a preview |
data:image/png;charset=utf-8;name=t.png;base64,, or either parameter alone | decoded.png |
DATA:IMAGE/PNG;BASE64, | decoded.png |
data:image/jpeg;base64, before PNG data | decoded.png and the note: The data URL says image/jpeg, but the bytes are a PNG image. The file is saved as .png. |
data:application/octet-stream;base64, before PNG data | decoded.png, no note |
data:application/octet-stream;base64, before plain text | decoded.bin: the Output file type list decides |
| An exclamation mark inside the string | This doesn't look like valid Base64 data. Check for typos or missing characters. |
data:image/png, without ;base64 | This doesn't look like valid Base64 data. Check for typos or missing characters. |
| A PNG or a JPEG cut to half its bytes, or text labelled image/png | This doesn't look like a valid image — it may be truncated or corrupted. Check that you copied the full string and try again. |
RFC 2397 lets a data URL's media type carry parameters such as charset or name before ;base64, and RFC 3986 says URI schemes are case-insensitive, so both forms above are read. MDN's data URL reference says a data URL with no media type is treated as text/plain;charset=US-ASCII; this page goes by the bytes instead, which is why the data:;base64, row still gives a PNG.
Long strings
Time from pressing Process to the download link, measured on one Mac. Both files came back byte for byte.
| Input | Chrome 158 | Firefox 155 | The WebKit build |
|---|---|---|---|
| 1,045,293-byte PNG of random pixels (1,393,724 characters) | 120 ms | 4,124 ms | 570 ms |
| 8,371,152-byte PNG of random pixels (11,161,536 characters) | 1,752 ms | 28,048 ms | 4,108 ms |
Decoding a string
Step 1
Paste the string
Either a bare Base64 string or a full data:image/png;base64,... URL. Spaces and line breaks inside it are ignored.
Step 2
Pick Output file type only if the type is not recognised
The page reads the first bytes of the decoded data and recognises PNG, JPEG, GIF, WebP, BMP, ICO, AVIF, SVG and PDF, so a bare string normally needs no choice. Data it cannot recognise and that has no data URL prefix uses the Output file type list; left on .bin, you get a file named decoded.bin with no preview.
Step 3
Decode, then download
A valid image shows a preview, and Download saves decoded plus the extension. The reset button clears the text and the result.
Going the other way
- To turn a picture into a string, Image to Base64 Converter writes the data URL form.
- For text rather than images, Base64 Encoder and Decoder is the general page.
Decoding questions
Why did I get decoded.bin and no preview?
The decoded bytes were not one of the types the page recognises from their first bytes (PNG, JPEG, GIF, WebP, BMP, ICO, AVIF, SVG, PDF), and there was no data:...;base64, prefix to say otherwise. Choose the type in the Output file type list and decode again.
Why does it say the image is truncated or corrupted?
The text decoded as Base64 but not as a complete picture. Cutting a test PNG at 10%, 50% and 90% of its text produced that message every time. Copy the whole string, and check that a chat app or log did not shorten it.
Does it accept SVG?
Yes. SVG data, with or without a data:image/svg+xml;base64, prefix, is checked by loading it as an image and not as a bitmap, then previewed. A data URL that is not Base64 is not read at all.
Does it accept the URL-safe alphabet?
Yes. - and _ are read as + and /, and missing = padding, spaces and line breaks are fine.
Can the label and the real format disagree?
Yes, and the page tells you. The first bytes decide the type: a JPEG labelled data:image/png is saved as decoded.jpg with a warning that the label was wrong.
Is the string sent anywhere?
No. It is decoded in the page, and the preview and file are built from memory.
Which picture formats get a preview?
PNG, JPEG, GIF, WebP, BMP, ICO, AVIF and SVG test files all showed a preview in Chrome 158, Firefox 155 and the WebKit build. A PDF is recognised and saved as decoded.pdf, without a preview.
Is the downloaded file identical to the original?
Yes. In every measured case the saved file was byte for byte the decoded data, up to an 8,371,152-byte PNG pasted as 11,161,536 characters.
Does a data URL with a file name in it work?
Yes. Parameters such as ;name=photo.png or ;charset=utf-8 before ;base64, are skipped, and an upper-case DATA: or ;BASE64, is read too.
What does a data:application/octet-stream label do?
Nothing on its own. It is a generic label, so PNG bytes under it are still saved as decoded.png without a note, and bytes the page does not recognise take their type from the Output file type list, decoded.bin by default.