Decode Base64 to Image
Paste a Base64 encoded image string to preview and download it as a file. This tool accepts both raw Base64 strings and complete data URIs (data:image/png;base64,…). The image format is detected automatically, and you can see a live preview before downloading.
How to Use
- Switch to the “Base64 to Image” tab above
- Paste a Base64 string or data URI into the input
- The tool detects the image format and shows a preview
- Click Download to save the image file
Where Base64 Images Come From
You encounter Base64 encoded images in many contexts:
API responses
Many APIs return images as Base64 strings in JSON. AI image generation APIs (DALL-E, Stable Diffusion, Midjourney API) commonly return results this way. Payment QR codes, captcha images, and dynamically generated charts also arrive as Base64.
Database records
Applications that store images in database text columns use Base64 encoding. When you retrieve these records, you need to decode them to view or save the images.
HTML and CSS source
Data URIs in <img> tags and CSS background-image properties contain Base64 images. Extracting the image from source code requires decoding the Base64 portion.
Email content
MIME encoded email attachments and inline images are Base64 encoded. Raw email source shows the Base64 data between MIME boundary markers.
JWT tokens
Some JWT tokens embed small images (like user avatars or QR codes) in their payload claims. Decode the JWT first with the JWT Decoder, then decode the Base64 image data here.
Image Format Detection
This tool identifies the image format from the first few bytes of the decoded data:
| Base64 prefix | Format | MIME type |
|---|---|---|
/9j/ | JPEG | image/jpeg |
iVBOR | PNG | image/png |
R0lGOD | GIF | image/gif |
UklGR | WebP | image/webp |
PHN2Zy | SVG | image/svg+xml |
Qk0 | BMP | image/bmp |
If the input is a data URI, the MIME type from the prefix is used directly. For raw Base64 without a prefix, the tool falls back to byte signature detection.
Decoding Base64 Images in Code
JavaScript (browser)
// From data URI
const img = new Image();
img.src = 'data:image/png;base64,' + base64String;
// To downloadable file
const binary = atob(base64String);
const bytes = new Uint8Array(binary.length);
for (let i = 0; i < binary.length; i++) {
bytes[i] = binary.charCodeAt(i);
}
const blob = new Blob([bytes], { type: 'image/png' });
const url = URL.createObjectURL(blob);
Python
import base64
from PIL import Image
from io import BytesIO
data = base64.b64decode(base64_string)
image = Image.open(BytesIO(data))
image.save('output.png')
Command line
echo "iVBORw0KGgo..." | base64 -d > output.png
Troubleshooting Decoded Images
Blank or broken image
The Base64 string may be truncated. Check that the length is a multiple of 4 and that no characters were lost during copy paste. Some text editors wrap long lines and introduce line breaks.
Wrong format
If the decoded file has the wrong extension, the content may still be valid. Try opening it in an image viewer that detects format from content rather than extension. This tool detects the actual format regardless of any claimed MIME type.
Oversized output
If the decoded image is unexpectedly large, the original may have been a high resolution uncompressed format. Consider converting to a more efficient format after decoding.
For the reverse operation, see Image to Base64 or format specific converters: JPG to Base64, PNG to Base64, SVG to Base64.