How to convert Base64 to an image
- Copy the string from wherever you found it and paste it into the box.
- Press “Show image”. The picture appears with its format, file size and dimensions.
- Press “Download image” to save it. The file ending is chosen to match the format, such as
decoded.png.
Want to test it first? This string decodes to a tiny red PNG, 2 pixels wide and 1 high:
iVBORw0KGgoAAAANSUhEUgAAAAIAAAABCAYAAAD0In+KAAAACXBIWXMAAAPoAAAD6AG1e1JrAAAADklEQVQImWP4z8DwH4QBEfcD/RSF9bkAAAAASUVORK5CYII=
What you can paste
- A full data URI, such as
data:image/png;base64,iVBOR… - The encoded text alone, with no prefix.
- A snippet that contains a data URI: a whole
<img>tag, a CSSurl()rule or a JSON value. The tool finds the data URI inside it. - URL-safe Base64, which RFC 4648 defines with
-and_in place of+and/. Missing=padding at the end is fine. - Text broken over several lines, as email and some command-line tools produce. Line breaks are ignored.
Telling the format from the first characters
Every image format starts with the same few bytes, so its Base64 form starts with the same few characters. You can often identify an image before decoding it:
| String starts with | Format |
|---|---|
iVBOR | PNG |
/9j/ | JPG |
R0lGOD | GIF |
UklGR | WebP (also other RIFF files, such as WAV audio) |
Qk | BMP |
The tool reads these signatures itself and trusts them over the label in a data URI. A JPG mislabelled as image/png is therefore shown and saved as what it really is. To see a picture’s real format once it is on disk, our guide to image file formats explains how.
Where these strings come from
You’ll usually find Base64 images in API responses, JSON exports and database fields that store a picture as text, in the source of HTML pages and emails, and in the output of JavaScript’s canvas.toDataURL(). Developers use it to carry a file through a system that only handles text. Base64 images vs URLs covers when that is a good idea.
How long will the decoded file be?
Base64 represents “24-bit groups of input bits as output strings of 4 encoded characters”, as RFC 4648 puts it. Every 4 characters therefore become 3 bytes, so the file is about three-quarters the length of the text. A string of 4 million characters holds a file of about 3 MB. A trailing = or == is padding and adds nothing to the picture. To relate that file size to its pixels, try the image size calculator.
Why a string might not work
- It was cut off. Logs, spreadsheet cells and preview panes often shorten long values. The picture then fails to display, or only part of it appears.
- It isn’t an image. Base64 can hold any file, and a token or a PDF will decode but can’t be shown as a picture.
- It’s SVG. SVG files can contain scripts, so this tool won’t display them.
- You tried the address bar. MDN notes that top-level navigation to
data:URLs “is blocked in all modern browsers” as a defence against phishing, so links to them often go nowhere. Pasting the string here avoids the problem.
Private by design
A string from an API or an internal system may hold something you wouldn’t want to send to a stranger’s server. Here the decoding runs in your browser, so the text and the picture stay on your device.
After you have the image
Going the other way? Image to Base64 encodes a file and gives you ready-made HTML, CSS and Markdown. If you need the picture somewhere public, upload it to get a direct link. To shrink it first, use the image compressor. If the decoded file is a WebP or AVIF that your software can’t open, convert it with WebP to JPG or AVIF to JPG.
