How to use the Base64 to Image
- Paste your Base64 string or data URI into the box. You can also paste a CSS rule or HTML tag that contains one.
- The image is decoded as you type. Check the preview, the detected format and the dimensions.
- If something is wrong, read the message under the box: it points to the invalid character or explains what is missing.
- Type a file name if you like and click Download; the correct extension is added automatically.
Features
- Accepts raw Base64, data URIs and URL-safe Base64
- Finds a data URI inside pasted CSS or HTML
- Detects the real format from magic bytes
- Warns when the declared MIME type is wrong
- Clear errors for invalid characters and cut-off strings
- Saves with the correct file extension
Where Base64 images come from
You will meet Base64-encoded images in many places: src attributes in HTML source, url() values in CSS files, JSON responses from APIs, the raw source of emails, database exports, browser developer tools and the output of canvas.toDataURL(). They all hold an ordinary image file, just written as text. This tool turns that text back into the file.
How the format is detected
A data URI declares a MIME type, but declarations can be wrong, and raw Base64 has none at all. So after decoding, the tool inspects the first bytes of the data, known as the file signature or magic number, which every image format starts with:
| Format | First bytes |
|---|---|
| PNG | 89 50 4E 47 0D 0A 1A 0A (".PNG") |
| JPEG | FF D8 FF |
| GIF | "GIF87a" or "GIF89a" |
| WebP | "RIFF", 4 size bytes, then "WEBP" |
| BMP | "BM" |
| ICO | 00 00 01 00 |
| AVIF / HEIC | "ftyp" at byte 4, followed by a brand such as avif or heic |
| TIFF | "II*" (little-endian) or "MM" then 00 2A (big-endian) |
| SVG | Text starting with <svg or an XML declaration |
A neat trick: Base64 for a PNG always begins with iVBORw0KGgo, a JPEG with /9j/ and a GIF with R0lGOD. If your string starts differently, it is probably not the format you expect.
Common reasons decoding fails
- The string is cut off. Copying from a log or a truncated database column often loses the end. Valid Base64 never has a length that leaves one stray character over after grouping in fours, so the tool can spot many truncations.
- Extra characters crept in. Quotes, backslashes from JSON escaping, or HTML entities such as
+are not part of Base64. The error message shows the first invalid character and its position. - Line breaks. Email systems wrap Base64 every 76 characters. Whitespace and line breaks are ignored here, so you can paste wrapped text as it is.
- URL-safe Base64. Some systems replace + and / with - and _. Those are converted back automatically.
- It is not an image. If the bytes match no image signature, you can still download the raw data to inspect it; a PDF is recognized and named as such.
Is it safe to decode untrusted strings?
Decoding happens entirely in your browser, and nothing is uploaded. The preview uses a standard image element, which displays pictures but never runs scripts, even for SVG files. Downloaded files are saved exactly as decoded, so treat files from unknown sources with the same care as any other download.
Need to create a data URI instead? Use Image to Base64. For non-image data, the Base64 Encoder/Decoder handles text and files.
Frequently asked questions
Do I need to include the data:image/png;base64, prefix?
No. Paste either the full data URI or only the Base64 part. Without a prefix, the format is worked out from the decoded bytes.
Why does it say my Base64 is invalid?
The text contains a character that Base64 does not use, such as a quote or backslash, or it has been cut off. The message shows the position of the first problem so you can fix it.
The data URI says PNG but the file downloads as JPG. Why?
The tool trusts the actual file signature rather than the label. If a data URI declares the wrong type, the file is saved with the extension that matches its real contents.
Can I decode Base64 that is not an image?
If the data is not a recognized image, you can still download it as a .bin file, and PDF documents are detected and saved as .pdf.
Is there a size limit?
There is no fixed limit. Very long strings of tens of megabytes depend on your device’s memory and may take a moment to paste.