Base64 to PNG Converter
Paste a Base64-encoded image string (with or without the data:image/…;base64, prefix) and decode it back into a downloadable image. Works for PNG, JPG, WebP and GIF. Runs in your browser.
What this tool does
This decoder reverses a Base64-encoded image string back into a real image file you can download. It accepts two input shapes: a complete data: URI like data:image/png;base64,iVBORw0KGgo… (which already tells the browser what format the image is) and raw Base64 with no prefix (in which case the tool auto-detects the format by inspecting the first few decoded bytes — the file signature, also called a "magic number").
The output is a real Blob — same as if you'd opened a downloaded file. You can preview it, save it to disk, or right-click to copy it into other apps.
Where Base64 image strings come from
- API responses — JSON endpoints frequently return avatars, captchas, signatures or small thumbnails as Base64 strings.
- HTML/CSS source — view-source of a web page often reveals inline
data:URIs inimg src,background-image, or SVGhrefattributes. - Email signatures — embedded logos are commonly Base64 to survive image-blocking.
- Mobile app debugging — adb logs and crash reports sometimes dump Base64 image payloads.
- SMS / chat attachments via APIs — Twilio, Telnyx, WhatsApp Business and similar return media as Base64 when you fetch them programmatically.
- Database BLOB exports — when an image column is exported as text, it's typically Base64.
- Configuration files — Kubernetes secrets, GitHub Actions artefacts, dotenv files.
How the decoder works
If your input includes the data: prefix, the tool reads the MIME type directly from it and trusts that label. If you paste raw Base64, the tool decodes the first 16 bytes and checks for known file signatures:
- PNG — starts with
89 50 4E 47 0D 0A 1A 0A(the bytes spell out "‰PNG\r\n\x1A\n"). - JPG — starts with
FF D8 FF. - GIF — starts with
47 49 46 38("GIF8"). - WebP — starts with
52 49 46 46("RIFF") followed by57 45 42 50("WEBP") at offset 8. - BMP — starts with
42 4D("BM"). - SVG — looks like XML or starts with
<?xmlor<svg.
Whichever format is detected, the tool builds a Blob with the correct MIME type and offers it for download.
Tips and troubleshooting
- "Invalid Base64" error — your string contains characters outside the Base64 alphabet. Usually this is a stray space, line break or HTML-entity-encoded character. Trim whitespace and re-paste.
- "Could not detect format" — the decoded bytes don't match any known image format. Either the Base64 isn't an image, or it's corrupted. Check that you copied the whole string and nothing extra.
- Output is the wrong format — if your prefix said
image/pngbut the actual bytes are a JPG, the tool trusts the prefix. Strip the prefix to force auto-detection from the bytes. - Padding errors — Base64 strings should be a multiple of 4 characters long, padded with
=if needed. Most decoders are forgiving but some aren't — try adding 1 or 2=to the end.
Common mistakes that break the input
- URL-encoded characters in the Base64 —
%2Binstead of+,%2Finstead of/,%3Dinstead of=. URL-decode first. - HTML-encoded characters —
+instead of+. Decode HTML entities first. - Base64-URL alphabet — uses
-_instead of+/. Replace those characters before decoding (most modern decoders handle both, but if yours doesn't, swap them manually). - The wrong field copied — sometimes the surrounding JSON includes the prefix but you pasted only the value after a quote, missing the start.
- Truncation — Base64 strings can be very long; some chat apps and editors truncate at copy time. Compare the length before/after to be sure.
How big will the decoded file be?
Base64 always inflates the data by about 33%. So a 4,000-character Base64 string decodes to roughly 3,000 bytes (3 KB). The exact formula: decoded_bytes ≈ encoded_chars × 3 / 4, minus a small amount for padding. A 100 KB image needs about 135 KB of Base64 to represent it.
FAQs
Do I need to keep the data: prefix when pasting?
No — the tool handles both. If the prefix is present it's used to set the MIME type; if not, the tool inspects the decoded bytes.
Will this work for non-image Base64?
It's designed for images. If you paste Base64 of, say, a PDF, the tool may not detect it correctly. Use a generic Base64 decoder for that.
Can I decode multiple strings at once?
Not yet — one at a time.
Is anything uploaded?
No. The decode runs in your browser using the atob and Blob APIs.
Is there a size limit?
Practical limit ~50 MB of Base64 text. Browsers slow down with very large strings.
Does this support Base64URL?
Yes — the tool replaces -_ with +/ before decoding.