Where Base64 images turn up
- API responses: signatures, QR codes, charts and ID photos often come back as a Base64 field in JSON.
- Web pages and CSS: small icons and backgrounds written straight into the code.
- Emails: the raw source of a message shows attached and inline pictures as Base64 blocks.
- Databases and logs: pictures stored as text columns, or dumped into a log file.
How the first bytes give the type away
| Type | First bytes | Base64 starts with |
|---|---|---|
| JPG | FF D8 FF | /9j/ |
| PNG | 89 50 4E 47 0D 0A 1A 0A | iVBORw0KGgo |
| GIF | 47 49 46 38 (GIF8) | R0lGOD |
| WebP | 52 49 46 46 … 57 45 42 50 | UklGR |
| SVG | <svg or <?xml | PHN2Zy or PD94bW |
| ICO | 00 00 01 00 | AAABAA |
So a string beginning /9j/ is a JPG whatever its label says, and one beginning JVBER is a PDF, which this page refuses because it isn’t a picture.
Worked example: a mislabelled icon
An API returns data:image/jpeg;base64,iVBORw0KGgo…. The bytes start 89 50 4E 47, so it is really a PNG: the tool shows it, notes that the label says image/jpeg,
and saves it as icon.png. Saving it as .jpg would have produced a file some apps refuse to open.
Fixing common copy-and-paste problems
- Quotes,
url(,src=and line breaks around the text are ignored, so paste the whole line. - “\n” sequences from JSON and spaces from wrapped emails are removed.
- Missing “=” padding at the end is added back.
- A string that ends abruptly was cut off: copy it again in full.
Need the opposite direction? Image to Base64 makes data URIs, CSS and HTML from a file.
Frequently asked questions
How do I convert Base64 to an image?
Paste the text into the box and press Show the picture (pasting shows it straight away). The picture appears with its type, size and dimensions; press Download to save it with the right extension.
What can I paste?
A full data URI (
data:image/png;base64,…), the bare Base64 text, a CSS url("data:…") line, an HTML <img src="data:…"> tag, URL-safe Base64 with - and _, or text broken over several lines. You can also open a .txt, .css, .html or .json file that contains it.How does it know the image type?
From the first bytes of the decoded file, the same “magic numbers” image apps use: FF D8 FF for JPG, 89 50 4E 47 for PNG, GIF8 for GIF, RIFF…WEBP for WebP, and so on. The type written in the data URI is only a label, so when it is wrong the tool tells you and saves the real type.
Why do I get an error?
Either the text contains characters Base64 never uses, it was cut off when copied (its length is impossible), or it decodes to something that is not a picture, such as a PDF or a ZIP. The message says which.
Is it safe to open Base64 from someone else?
The picture is only shown as an image, never run as a page, so scripts hidden inside SVG files don’t run here. Be careful where you open the saved file afterwards, as you would with any download.
Last updated: 2026-11-26