Skip to content
PictureToLink logoPictureToLink
Menu

Base64 to image

Paste a Base64 string or data URI to see the picture and save it as a file. The text is decoded in your browser and never leaves your device.

How to convert Base64 to an image

  1. Copy the string from wherever you found it and paste it into the box.
  2. Press “Show image”. The picture appears with its format, file size and dimensions.
  3. 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 CSS url() 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 withFormat
iVBORPNG
/9j/JPG
R0lGODGIF
UklGRWebP (also other RIFF files, such as WAV audio)
QkBMP

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.

Questions and answers

How do I turn Base64 into an image?

Paste the text into the box above and press “Show image”. The tool decodes it in your browser, shows the picture, and gives you a button to download it as a normal image file.

Do I need the “data:image/png;base64,” part?

No. Paste the whole data URI or only the encoded text after the comma. Without the prefix, the tool works out the format from the first bytes of the decoded data.

Why do I get “That isn’t valid Base64”?

The text contains characters Base64 doesn’t use, or it was cut off in a way that leaves an impossible length. Copy the string again from its source and make sure you have all of it.

Why is the image broken or only partly there?

The string was probably truncated, which often happens with long values in logs, previews and spreadsheet cells. Go back to the original source for the complete text.

Why can’t I preview SVG here?

SVG files can contain scripts, so this tool doesn’t display them. Only open SVG data that comes from a source you trust.

Is the text I paste sent anywhere?

No. Decoding uses functions built into your browser, and nothing goes to our servers. That makes it reasonable for images from private API responses or internal systems.