Base64 to Image Converter

Previews and downloads an image that sits as text in an API response, a log entry or a database field. Also covers type detection and how to fix the most common Base64 errors.

The output will appear here.
Advertisement Clicker Alchemist — a mobile game by icyabmod, on Google Play and the App Store

How Base64 to Image Converter works

Previews and downloads an image that sits as text in an API response, a log entry or a database field. Also covers type detection and how to fix the most common Base64 errors.

Input Base64 / Data URI
Output Downloadable image
Works done 0

How to use it

A Base64 to image converter turns a picture stored as text, in an API response, a log entry or a database column, back into a file you can open. Paste a data URI or a raw Base64 string: the tool identifies the type from the byte signature, shows a preview with pixel dimensions and file size, and lets you download it with the correct extension. Decoding happens in your browser.

How to convert Base64 to image

  1. Paste the Base64 text, or a data URI starting with data:image/…;base64,, into the input field.
  2. Do not bother cleaning up line breaks and spaces; they are ignored, and URL-safe (base64url) strings are accepted too.
  3. Look at the preview and the details below it: detected type, width × height and file size.
  4. Download the image; it is saved with an extension that matches its type, such as image.png or image.jpg.
  5. If you get an error message, work through the debugging list below.

How the image type is detected

The tool decides the type from the signature at the start of the decoded bytes, not from the data URI header or the file name you expect. PNG, JPG, GIF, WebP, BMP, ICO and AVIF are recognized this way; if the decoded text begins with an <svg tag, the data is treated as SVG. You can often make a rough guess yourself from the first characters of the string:

String starts withLikely content
iVBORw0KGgoPNG
/9j/JPG (JPEG)
R0lGODGIF
UklGRRIFF container; WebP for images
QkBMP
AAABAAICO
PHN2ZySVG (text starting with <svg)
JVBERi0PDF; not an image

The table is for a quick visual check; the tool always decides by inspecting the decoded bytes. AVIF files do not share one fixed prefix because their first box size varies, but the tool detects them as well.

When the data URI declares the wrong type

Some services return every image with a data:image/png header even when the content is JPEG. Browsers usually tolerate the mismatch silently, but save the file with the wrong extension and certain programs refuse to open it. Here, when the header and the content disagree, the content wins: if the bytes are JPEG, the download arrives as .jpg. If you see this mismatch in your own API, it is a good moment to review the MIME type setting on the server side.

Debugging: the usual suspects

  • Invalid Base64 error and JSON escaping: some JSON encoders escape forward slashes as \/. Backslashes are not part of the Base64 alphabet. Copy the value from the parsed field rather than the raw JSON text, or open the payload in the JSON formatter and take the right field from there. Leftover quotation marks at either end cause the same error.
  • Truncated log entries: logging systems often cut long values at a fixed length and append an ellipsis or a marker. Such a string is either rejected or produces an image with a missing part. Take the full value from the network response or the database.
  • Valid Base64, but not an image: the string is valid Base64 but does not contain a picture. Starting with JVBERi0 means PDF, UEsDB means ZIP or an Office document; to check whether it is plain text, decode it with the Base64 encoder and decoder.
  • Double-encoded data: a string beginning with aVZCT is very likely the Base64 of a PNG encoded a second time. Decode it once with the text decoder and paste the resulting iVBOR… string here.

SVG previews and safety

An SVG is a document as much as a picture, and it can contain scripts. The tool shows SVGs inside an image element, so no script runs during the preview. Before opening a downloaded SVG file directly in a browser, though, make sure you trust its source, especially when the data came from user uploads.

After decoding

If the image turns out to be WebP or AVIF and will not open in some program, a converter such as WebP to JPG moves it to a format that opens everywhere. Going the other way, when you need to turn a picture into text for test data or an API request, use the image to Base64 converter. For the background on the encoding itself, read what Base64 is.

Where your data is processed

The text you paste is decoded by JavaScript running in your browser; it is not transmitted to our server, and the page only increments an anonymous usage counter. That detail matters when you are inspecting sensitive values from a live system, such as users' ID photos or signature images.

Advertisement icyabmod — get a website for your business, design it on a live demo

Frequently asked questions

Paste the Base64 text, or a data URI starting with data:image, into the field on this page. The tool decodes it in your browser, detects the image type from the bytes and shows a preview. You can then download the image with the correct extension. Line breaks and spaces are fine, so wrapped text copied from an email source or a log works too.

The easiest way is to paste it into the tool; the detected type appears below the preview. If you want to check by eye, the opening characters give a hint: iVBORw0KGgo is PNG, /9j/ is JPEG, R0lGOD is GIF, UklGR is usually WebP, Qk is BMP and AAABAA is ICO. The type in a data URI can be wrong, which is why the tool relies on the decoded byte signature.

The text contains characters outside the Base64 alphabet, or the string is incomplete. The usual causes are backslashes left over from JSON escaping, quotation marks picked up while copying, and logging systems that truncate long values. Take the value straight from the parsed JSON field or the database. Spaces, line breaks and base64url characters do not cause this error.

Most of the time the Base64 string was cut off somewhere. Even when the Base64 itself looks valid, a missing end of file can leave the lower part of the image grey, blank or not drawn at all. Get the complete value from the network response or the database instead of a log line. If the source system saved the image incorrectly, the problem lies in the data, not in the decoding.

The preview is safe, because the SVG is displayed inside an image element and browsers do not run scripts in that context. If you open the downloaded file directly in a browser, however, scripts inside it can run. Do not open SVGs from unknown sources that way; look at the contents in a text editor first or convert the file to PNG before using it.