Base64 to Image
Paste a Base64 string to securely preview and download it as an image file on your local device.
Base64 to Image Decoding
A Base64 image string is a text representation of binary image data. Decoding reverses the Base64 encoding to recover the original image file — useful for extracting images embedded in code, API responses, or database fields.
Base64 Image Data URI Format
- Full data URI:
data:[mime-type];base64,[encoded-data] - Example:
data:image/png;base64,iVBORw0KGgo... - The MIME type tells the browser how to interpret the data
- Common MIME types:
image/png,image/jpeg,image/svg+xml,image/webp - Raw Base64 (without the data: prefix) can also be pasted for decoding
Where You Find Base64 Images
- HTML/CSS source code with embedded images
- REST API responses returning image data as JSON strings
- Database BLOB fields stored as Base64
- Email HTML with inline attachments
How do I decode Base64 to an image in JavaScript?
Convert to a Blob and create an object URL: const bytes = atob(base64); const arr = new Uint8Array(bytes.length); for (let i = 0; i < bytes.length; i++) arr[i] = bytes.charCodeAt(i); const blob = new Blob([arr], {type: 'image/png'}); const url = URL.createObjectURL(blob); Then set this URL as an <img> src.
Why does my Base64 string not decode to a valid image?
Common causes: (1) The string is truncated — Base64 images can be hundreds of thousands of characters long. (2) The MIME type in the data URI doesn't match the actual image format. (3) The Base64 was generated from a corrupted file. (4) There are line breaks or spaces in the Base64 string that need to be stripped before decoding.
Is it safe to decode unknown Base64 image strings?
Decoding Base64 in the browser is safe — it's just a text-to-binary conversion. However, the resulting image file could potentially contain malicious EXIF data or exploit image parser vulnerabilities. For security-sensitive contexts, run decoded images through a server-side image sanitizer before displaying or storing them.