Decode Base64 back into an image
Paste a Base64 string — either a bare payload or a full data: URI — and get
the image back, ready to view and download. This is the reverse of embedding
an image as Base64 in CSS, HTML or JSON, and it is handy for inspecting data URIs
pulled from a stylesheet, API response or saved page.
How it works
If the input starts with a data:image/...;base64, prefix, the tool reads the
exact MIME type from it. For a bare payload it decodes the bytes and sniffs the
type from the file’s magic numbers — for example a PNG starts with 89 50, a
JPEG with FF D8, and a BMP with 42 4D. The decoded bytes are wrapped in a
Blob of the right type, rendered as a preview, and offered for download with the
matching extension.
Example
Pasting data:image/png;base64,iVBORw0KGgo... shows the PNG preview and offers a
.png download. Pasting the same payload without the prefix still works — the
leading bytes 89 50 4E 47 identify it as PNG automatically.
| Detected bytes | Image type | Extension |
|---|---|---|
89 50 | PNG | .png |
FF D8 | JPEG | .jpg |
47 49 | GIF | .gif |
42 4D | BMP | .bmp |
Everything happens in your browser with the built-in atob and Blob APIs —
nothing is uploaded.
When you need to decode a base64 image
The most common scenario is inspecting or extracting an image that arrived embedded in a data context rather than as a standalone file:
- Stylesheets and HTML: A CSS background or an
<img>tag may carry adata:image/...;base64,...URI directly. View-source or DevTools reveals the payload; paste it here to see and save the image. - API responses: Many image APIs return thumbnails or previews as base64 strings inside a JSON payload, particularly when the caller must remain completely serverless or the image is short-lived.
- Email attachments in raw MIME: Inline images in HTML email are often embedded as Content-Transfer-Encoding: base64 blocks. Extract the block and decode it to verify the attachment.
- Debug logging: Developers sometimes log base64-encoded images to trace pipelines for screenshots, OCR inputs, or computer-vision API calls. Decoding restores the visual for inspection.
Understanding the magic-number sniffing
If you paste a bare base64 payload without a data: prefix, the tool identifies the image type from the first decoded bytes — the file’s magic number:
| First bytes (hex) | Format | Extension |
|---|---|---|
89 50 4E 47 | PNG | .png |
FF D8 FF | JPEG | .jpg |
47 49 46 38 | GIF | .gif |
52 49 46 46 ... 57 45 42 50 | WebP | .webp |
42 4D | BMP | .bmp |
3C 73 76 67 (or variant) | SVG | .svg |
Magic number sniffing works because every major format reserves specific bytes at byte offset zero — a “signature” designed precisely for format detection. The MIME type in a data URI is more reliable when available, so the tool uses it first and falls back to byte-sniffing only for bare payloads.
Troubleshooting a broken decode
If the preview shows a broken or blank image, the most common causes are: the payload was truncated during copy (base64 strings can be long and break at line-wraps), the string includes URL percent-encoding that needs to be decoded first (%2B instead of +), or the data is not an image at all — it may be a different binary format that happens to be base64-encoded. The tool shows the byte count after decoding to help diagnose truncation.