Home › Converters › Base64 to Image Converter
Base64 to Image Converter
Turn a base64 string back into a picture with this free base64 to image converter. Paste the code, see the image appear instantly, and check its format, dimensions, and file size — then download it as a PNG. Everything runs in your browser, so your image never leaves your device.
Paste the base64 code with or without the data: prefix (for example, data:image/png;base64,...). The sample above is a 1×1 red pixel.
Reverse: image to base64
How it works
Base64 is a way of writing binary data as plain text. An image file is a stream of bytes, and bytes cannot travel safely inside text — in an email, a web page, or a settings file — because some byte values mean something special there, or get stripped out entirely. Base64 solves that by regrouping the bytes into 6-bit chunks and writing each chunk as one of 64 safe characters: the letters A to Z, a to z, the digits 0 to 9, and the symbols + and /. Padding characters (=) are added at the end when the length does not divide evenly. The result is ordinary text that any system can store and pass along, at the cost of growing about a third larger than the original file.
To turn a base64 string back into an image, this converter first cleans it up: it strips any data: prefix, removes spaces and line breaks, and checks that only valid base64 characters remain. Then it decodes the text back into bytes and looks at the first bytes of the result — the file's "magic bytes" — to work out what kind of image it is. A PNG file always starts with the bytes 89 50 4E 47, a JPEG starts with FF D8 FF, a GIF starts with the letters GIF8, and a WebP file starts with RIFF followed by WEBP. If the string came with a data: prefix, the MIME type written there is used instead, which is how the converter also handles SVG images, which are text rather than binary.
Once the bytes are recovered, the browser draws them as a normal image, which is how the preview, the width and height, and the file size are all measured. The file size is simply the number of decoded bytes — a useful check, because base64 text is about 33 percent longer than the file it encodes, so a 100-kilobyte image becomes roughly 137 kilobytes of text. That is why base64 is handy for small images, like icons and logos, but a poor choice for large photos: pasting a big photo as text makes pages and emails noticeably heavier.
The download button saves the decoded picture as a PNG. If the original was already a PNG, the file is saved exactly as decoded. If it was a JPEG, GIF, or WebP, the converter draws it onto a canvas and exports a PNG copy, so you always get a widely supported file. The reverse direction works the same way in reverse: pick an image file from your device, the browser reads it and encodes its bytes as base64, and you can copy the result to paste into a web page or a document. Nothing is uploaded in either direction — the whole job happens on your device.
Common image formats
| Format | MIME type | Starts with | Best for |
|---|---|---|---|
| PNG | image/png | 89 50 4E 47 | Logos, icons, screenshots |
| JPEG | image/jpeg | FF D8 FF | Photos |
| GIF | image/gif | GIF8 | Simple graphics, animation |
| WebP | image/webp | RIFF ... WEBP | Smaller web images |
| SVG | image/svg+xml | <svg | Scalable icons and drawings |
Worked example
Take the classic test string for a 1×1 red pixel, which is already loaded in the box above: iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==
Step 1: Paste the string into the box and press "Show image".
Step 2: The converter strips nothing here — there is no data: prefix — and decodes the 96 characters of text into bytes.
Step 3: The first bytes are 89 50 4E 47, the PNG signature, so the MIME type is image/png.
Step 4: The decoded file is 70 bytes long, and the image measures 1 pixel wide by 1 pixel tall.
Step 5: The preview shows a single red pixel, and "Download as PNG" saves it as image.png.
Try adding the prefix yourself — data:image/png;base64, followed by the same string — and the result is identical, because the converter reads the MIME type from the prefix and decodes the part after the comma. If you paste the string with line breaks in the middle, it still works: line breaks are ignored before decoding.
FAQ
What is base64?
Base64 is a way of writing binary data, such as an image file, as plain text using 64 letters, digits, and symbols. It lets an image travel inside text — in an email, a web page, or a settings file — where raw binary bytes would break things.
How do I turn a base64 string back into an image?
Paste the string into the box above and press Show image. The converter decodes it, shows a preview, and reports the format, dimensions, and file size. You can then download the result as a PNG. A data: prefix is optional — the tool works with or without it.
What image formats can this converter open?
PNG, JPEG, GIF, WebP, BMP, and SVG. The format is detected from the data: prefix when one is given, and otherwise from the file's magic bytes — the first few bytes of the decoded data, which are different for each format.
Why does my base64 string not work?
The most common causes are a truncated string, spaces or line breaks in the wrong place (though this tool ignores them), characters outside the base64 alphabet, or missing = padding at the end. Copy the full string again from the source, and make sure nothing was cut off.
Is my image uploaded anywhere?
No. Decoding, previewing, downloading, and the reverse image-to-base64 direction all happen in your browser on your own device. The string you paste and the image you pick are never sent to a server.