Base64 to image — decode a data URI and save the picture

Paste a data URI such as data:image/png;base64,… or a bare Base64 string, and the tool decodes it, checks which image format the bytes really are, shows the picture and lets you download it.

Live demo · real result from this tool

Your result appears here.

Processed on your device — nothing is uploaded.

How to use Base64 to Image

  1. Paste the text into Data URI or Base64. The box starts with a small sample PNG so you can see how it works.
  2. The result appears as you type: the picture, its Size in pixels, its Format and the number of Bytes.
  3. Read any warning, such as a type mismatch.
  4. Download the image. The file is named image plus the real extension, for example image.png or image.gif.

What it does and when to use it

Images often travel as text: inside HTML and CSS as data URIs, in JSON from an API, in email source code, in database exports and in logs. This tool turns that text back into a picture you can see and save. Developers use it to check what an API actually returned, to recover an icon from a stylesheet, or to debug a broken inline image.

To go the other way, use Image to Base64. For Base64 that holds text or other files rather than pictures, use Base64 Decode. To learn more about the decoded file, such as bit depth and transparency, save it and open it in Image Info.

How it works

The tool trims the input and checks for a data: prefix. For a ;base64, URI, or bare Base64, it removes whitespace, maps URL-safe characters back to standard ones, restores padding and decodes the bytes. A plain data: URI without Base64, common for SVG, is URL-decoded instead. The first bytes of the result are matched against known image signatures to find the real format, and the header is read for the pixel size.

Worked examples

Outputs from the tool’s own function.

A tiny GIF. R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 decodes to a GIF of “Size: 1 × 1 px” and 42 B, the classic single-pixel image used in emails.

Text, not a picture. SGVsbG8gd29ybGQ= decodes fine but gives “Decoded 11 bytes, but they are not an image format we recognise”. Those 11 bytes are the words “Hello world”.

Not Base64 at all. not base64! contains an exclamation mark, which is not a Base64 character, so the answer is “This is not Base64 or a data: URI.”

A wrong label. The sample PNG pasted with the prefix data:image/jpeg;base64, still shows as a 24 × 24 px PNG, with a warning to use data:image/png;base64 instead.

Limits and tips

  • To change the decoded picture’s size or format, download it and use the Image Converter.
  • An animated GIF previews as animated, but Size reports only the canvas size.
  • SVG sizes come from the width and height attributes, or the viewBox if those are missing.

Frequently asked questions

Do I need the data:image/…;base64, part at the start?
No. Both a full data URI and the bare Base64 text work. Without the prefix, the tool works out the format from the decoded bytes.
Why does it warn that the URI type does not match?
The data URI declares one type but the bytes are another, for example data:image/jpeg holding a PNG. Browsers may refuse to show such an image, so the tool tells you the correct prefix to use.
My string has line breaks and no = at the end. Will it work?
Yes. Spaces and line breaks are removed, missing = padding is added, and the URL-safe characters - and _ are accepted as well.
Which formats are recognised?
PNG, JPEG, GIF, WebP, BMP, AVIF, HEIC, TIFF, ICO and SVG. Anything else is reported with its byte count so you know the decoding itself worked.
Is the string sent anywhere?
No. Decoding happens in your browser, and the preview is built from the decoded bytes.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close