User Rating 0.0
Total Usage 0 times
Drop a .txt / .b64 file here or click to browse Supports drag & drop, file upload, and clipboard paste
0 characters ~0 B decoded
Your PNG preview will appear here
Is this tool helpful?

Your feedback helps us improve.

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.

base64 png image converter decode base64 base64 to image png download image decoder

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:

Sencoded = 4 Sbytes3

where the division is rounded up (ceiling). To reverse this and estimate the decoded binary size from a Base64 string of length L:

Sbytes = 34 L P

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

PropertyBase64 EncodingPNG Format
TypeText (ASCII subset)Binary (raster image)
Character SetA-Z a-z 0-9 + / =N/A (binary stream)
Size Overhead~33% larger than binaryLossless compression
MIME Typetext/plainimage/png
CompressionNone (encoding only)DEFLATE (zlib)
TransparencyDepends on sourceAlpha channel supported
Color DepthDepends on sourceUp to 48-bit + 16-bit alpha
Max DimensionsN/A231 1 pixels per axis
Magic Bytes (hex)N/A89 50 4E 47 0D 0A 1A 0A
File Extension.b64 / .txt.png
Use CaseInline embedding (CSS, HTML, JSON)General-purpose lossless images
Browser SupportAll modern browsers (atob)Universal
Lossy ArtifactsPreserves source artifactsNone added (lossless)
Padding Character= (1 or 2 at end)N/A
Line Length (MIME)76 chars per RFC 2045N/A
Data URI Prefixdata:image/png;base64,N/A

Frequently Asked Questions

No. JPEG compression is lossy and discards high-frequency data permanently. Converting the decoded JPEG pixels to PNG preserves them losslessly from that point forward, but the original artifacts (block boundaries, color banding) remain baked into the pixel grid. The output PNG will be larger than the JPEG source because PNG's DEFLATE compression is lossless and less efficient for photographic content.
Common causes: (1) The string contains line breaks or carriage returns inserted by MIME formatting (RFC 2045 allows lines of 76 characters). Strip all whitespace before decoding. (2) The string has been URL-encoded, replacing + with %2B and / with %2F. Reverse the URL encoding first. (3) The string uses Base64URL variant (- and _ instead of + and /). This tool auto-detects and converts Base64URL to standard Base64 before decoding.
Browser memory is the practical limit. The atob function and Canvas API operate in main-thread memory. A Base64 string of 10 MB decodes to roughly 7.5 MB of binary, which then inflates further when drawn to a Canvas (width × height × 4 bytes for RGBA). For a 4000 × 3000 image, that is 48 MB of canvas memory. The tool warns above 10 MB input but does not block the attempt.
Yes. If the source image encoded in Base64 contains an alpha channel (PNG, WebP, GIF), the decoded image retains it. The Canvas API draws with alpha compositing enabled, and toBlob with image/png MIME type produces a 32-bit RGBA output. JPEG sources have no alpha channel, so the output PNG will have fully opaque pixels.
Yes. The tool detects the data: prefix and automatically strips everything before the comma (the MIME type declaration and ;base64, marker). Only the raw Base64 payload is sent to the decoder. The original MIME type is displayed in the metadata panel for reference.
Two factors. First, the Base64 string may encode a JPEG or WebP, both of which use lossy compression far more efficient for photographs than PNG's lossless DEFLATE. Second, PNG stores raw pixel data with lossless compression. A photographic image that was 50 KB as JPEG may become 500 KB as PNG. For size-sensitive use cases, consider keeping the decoded image in its original format rather than forcing PNG.