A Base64 image is just the original file written as text. To get the picture back, you decode that text into bytes and save them with the right extension. Here is how it works in the browser and in scripts.
Decode in the browser
The quickest path is to paste the string into the Base64 to Image tool. It reads the file signature and renders the picture instantly, with no upload.
In your own code, assign the data URL to an image element:
const img = new Image();
img.src = `data:image/png;base64,${b64}`;
document.body.append(img);Save bytes in Node.js
import { writeFileSync } from 'node:fs';
writeFileSync('image.png', Buffer.from(b64, 'base64'));Decode in Python
import base64
with open("image.png", "wb") as f:
f.write(base64.b64decode(b64))How to tell the format
The first characters name the format. A PNG starts with iVBORw0KGgo, a JPEG with /9j/, a GIF with R0lGOD and a WebP with UklGR.
iVBORw0KGgo→ PNG/9j/→ JPEGR0lGOD→ GIFUklGR→ WebP