About the Base64 to Image
Paste a Base64 string or a data URI to convert Base64 to an image you can see and download. The converter finds the real file type, shows the dimensions and size, and saves the picture as PNG, JPG, WebP or its original format.
Base64 images turn up in API responses, database columns, HTML emails, CSS files and logs. Copying one out is where things go wrong: the string gets cut off, picks up escapes from JSON, or carries the wrong type in its data: prefix. You can paste the string as it is, even inside an <img> tag, a CSS url() or a JSON value, and you'll get either the image or a message that says exactly what's wrong. The decoding runs in your browser.
- Paste into the Base64 or data URI box. The
data:image/...;base64,prefix is optional, and line breaks, URL-safe characters (-and_) and missing=padding are fine. Open File reads a.txtfile, and Load Example shows toolo's icon. - The image appears about 0.3 seconds later, with its real type, dimensions and size underneath.
- Read any note in amber: it tells you when the data looks cut off or when the data URI names a different type than the data really is.
- Pick a format in the list (Original, PNG, JPG or WebP) and click Download. Converting to JPG fills transparent areas with white.
- Copy Image puts the picture on your clipboard as PNG, ready to paste into a chat or document. Copy Data URI gives you a clean
data:string with the correct type, whatever you pasted.
Input{"logo":"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1AAAB\/lBMVEVMaXEdHR0..."}OutputType: PNG (image/png)
Dimensions: 48 × 48 px
Size: 1.2 KBPHP's json_encode writes every / as \/ unless you pass JSON_UNESCAPED_SLASHES. Many decoders choke on the backslashes; this one reads past them and finds the image.
InputiVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAMAAABg3Am1... (the first 1,200 of 1,692 characters)OutputType: PNG (image/png)
Dimensions: 48 × 48 px
Size: 900 B
The data looks cut off. A PNG ends with an IEND chunk, and this data has none.Database columns, log lines and terminal windows often cut long strings. A cut PNG may still show its top rows, so the image alone doesn't tell you anything is missing.
InputiVBORw0KGgo=iVBORw0KGgo=OutputNot valid Base64: "=" padding at character 12 is followed by more data. It looks like two Base64 strings joined together.The = sign only pads the end of a Base64 string. Seeing one in the middle almost always means two values were concatenated.
Why a Base64 image won't decode
The usual causes, and what the converter does with each:
- It was cut off. Every format has a fixed ending: PNG an
IENDchunk, JPEG anFF D9marker, GIF a;byte, and WebP stores its own length. A missing ending gets an amber note. - JSON escapes. PHP writes
/as\/, and .NET'sSystem.Text.Jsonwrites+as\u002Bby default. Both are read correctly here; elsewhere, decode the JSON first. - Spaces instead of
+. When Base64 passes through a URL query string unencoded, each+turns into a space. Spaces are read as+again. - Line breaks every 64 or 76 characters, from PEM files and MIME email. They are ignored.
- A stray character such as a quote,
#or%. The error names the character and its position, counting from the start of what you pasted. - It isn't an image. A PDF or ZIP decodes fine but has nothing to show. The Base64 Decoder saves any file type.
The type in the data URI vs. the real type
A data URI names a type, like data:image/jpeg;base64,, but the bytes may say otherwise, often because code hard-codes image/jpeg for every upload. In an <img> tag Chrome looks at the bytes and shows PNG, JPEG, GIF and WebP whatever the label says. SVG is different: labeled anything but image/svg+xml, it shows nothing.
Other software trusts the label: mail clients, image CDNs and upload checks that compare the MIME type. The converter reads the type from the first bytes, warns when it differs from the label, and uses the real type for Download and Copy Data URI. The first few Base64 characters give it away too: iVBORw0KGgo is PNG and /9j/ is JPEG. Image to Base64 lists the others.
Saving as PNG, JPG or WebP
Original saves the decoded bytes untouched, so nothing is lost. PNG, JPG and WebP redraw the image in your browser first:
- JPG can't store transparency, so transparent pixels become white.
- JPG and WebP are saved at quality 0.92 (out of 1). Pick PNG when every pixel must stay exact.
- An animated GIF keeps only its first frame.
- An SVG is drawn at its own size. For a bigger PNG of an SVG, use the SVG Viewer, where you set the width.
Save Base64 as an image file in code
Each snippet takes a data URI, drops everything up to the comma and writes the bytes to a file. With plain Base64, skip the split.
// fetch() understands data URIs and returns the bytes with their type.
const blob = await (await fetch(dataUri)).blob();
const url = URL.createObjectURL(blob);
const a = Object.assign(document.createElement("a"), { href: url, download: "image.png" });
a.click();
URL.revokeObjectURL(url);import { readFileSync, writeFileSync } from "node:fs";
const dataUri = readFileSync("uri.txt", "utf8");
const base64 = dataUri.split(",")[1];
writeFileSync("image.png", Buffer.from(base64, "base64"));import base64
data_uri = open("uri.txt").read()
b64 = data_uri.split(",", 1)[1]
with open("image.png", "wb") as f:
f.write(base64.b64decode(b64))# Plain Base64 in a file (strip the data: prefix first)
# macOS
base64 -d -i image.txt -o image.png
# Linux
base64 -d image.txt > image.png<?php
$dataUri = file_get_contents("uri.txt");
$base64 = explode(",", $dataUri, 2)[1];
file_put_contents("image.png", base64_decode($base64));How do I convert Base64 to an image?
Paste the Base64 or data URI into the box, check the preview, pick a format and click Download. It works with or without the data:image/...;base64, prefix.
Why is my Base64 image not showing?
Most often the string was cut off, contains a stray character, or isn't an image at all. The converter names the problem: a missing file ending, the bad character and its position, or the type it found instead.
How do I know what type of image a Base64 string is?
Paste it here and the Type line shows the format read from the file's first bytes. By eye, iVBORw0KGgo means PNG, /9j/ JPEG, R0lGOD GIF and UklGR WebP.
Do I need the data:image/png;base64, prefix?
Not here: plain Base64 works too. In HTML src attributes and CSS url() you do need it, and Copy Data URI adds it with the correct type.
How do I convert Base64 to PNG or JPG?
Choose PNG or JPG in the list next to Download. The image is redrawn in your browser, and with JPG, transparent areas turn white.
Can I convert an image back to Base64?
Yes, with Image to Base64. It gives a data URI, plain Base64, an HTML tag, CSS or Markdown.
Is the image sent to a server?
No. The Base64 is decoded in your browser tab and nothing is uploaded, which matters when the string comes from a private API response, a customer upload or an ID document.