Base64 to PNG Converter
Convert Base64 encoded strings to PNG images instantly. Paste, upload, or drag-and-drop Base64 data to decode and download as PNG files.
About
Base64 encoding inflates binary data by approximately 33% due to the 6-bit-to-8-bit mapping (3 source bytes become 4 ASCII characters). Embedding encoded images directly in CSS or HTML avoids an HTTP round-trip but makes payloads heavier and debugging harder. This tool reverses that transformation: it decodes the Base64 stream back into raw bytes, validates the result as a recognizable image, then re-exports it as a lossless PNG via the Canvas API. If the input is malformed or truncated, the decode will fail silently in most editors. Here you get explicit error reporting at the byte level.
The converter accepts both raw Base64 strings and full Data URI strings (e.g., data:image/jpeg;base64,...). It automatically strips the prefix before decoding. Output is always PNG regardless of the original source format. Note: conversion to PNG from a lossy source like JPEG does not restore lost data. The pixel grid is preserved exactly, but no information is recovered. Pro tip: if your Base64 string comes from an API response, verify that transport encoding has not added line breaks or whitespace. RFC 4648 permits line feeds in MIME contexts, but atob in browsers rejects them.
Formulas
Base64 encoding maps every group of 3 input bytes (24 bits) to 4 ASCII characters (6 bits each). The encoded size is computed as:
where the division is rounded up (ceiling). To reverse this and estimate the decoded binary size from a Base64 string of length L:
where Sencoded = size in Base64 characters, Sbytes = original binary size in bytes, L = length of Base64 string (excluding whitespace), and P = number of padding = characters (0, 1, or 2). The decode pipeline in this tool follows: Base64 string → atob → Uint8Array → Blob(image/*) → Image element → Canvas drawImage → toBlob(image/png).
Reference Data
| Property | Base64 Encoding | PNG Format |
|---|---|---|
| Type | Text (ASCII subset) | Binary (raster image) |
| Character Set | A-Z a-z 0-9 + / = | N/A (binary stream) |
| Size Overhead | ~33% larger than binary | Lossless compression |
| MIME Type | text/plain | image/png |
| Compression | None (encoding only) | DEFLATE (zlib) |
| Transparency | Depends on source | Alpha channel supported |
| Color Depth | Depends on source | Up to 48-bit + 16-bit alpha |
| Max Dimensions | N/A | 231 − 1 pixels per axis |
| Magic Bytes (hex) | N/A | 89 50 4E 47 0D 0A 1A 0A |
| File Extension | .b64 / .txt | .png |
| Use Case | Inline embedding (CSS, HTML, JSON) | General-purpose lossless images |
| Browser Support | All modern browsers (atob) | Universal |
| Lossy Artifacts | Preserves source artifacts | None added (lossless) |
| Padding Character | = (1 or 2 at end) | N/A |
| Line Length (MIME) | 76 chars per RFC 2045 | N/A |
| Data URI Prefix | data:image/png;base64, | N/A |