How do you save Base64 code as an image file?
You have a long piece of text starting with data:image/… and you need the picture inside it — from finding the code to saving the file.
By Metin Ersoy · Updated November 10, 2026
What is a Base64 image, and why is it text?
Base64 is a way of writing a file using only letters, digits and a few symbols. That lets a picture fit into places that can only carry text: a JSON response, an HTML page, the raw source of an email or a text column in a database. The text carries the image byte for byte; decode it and you get the original file back, complete.
The code usually comes in one of two forms:
- Data URI: it starts with a short label such as
data:image/png;base64,followed by the code. The label tells you the file type. - Bare code: no label, it starts straight away with something like
iVBORw0KGgo…. APIs usually give the type in a separate field.
1. Find the code and copy all of it
The easiest way depends on where the code lives:
- JSON or an API response: find the field holding the picture (often named image, photo, data, content or b64_json). Copy all the text between the quotes; taking the quotes too is fine.
- HTML or CSS: in the page source, find the
src="data:image/…orurl("data:image/…part. Copying the whole img tag or CSS rule also works — the tool picks the code out by itself. - Raw email source: in the "show original" view, attachments sit below a Content-Transfer-Encoding: base64 line as a block split into lines. Copy the whole block up to the blank line; the line breaks don't matter.
- Browser developer tools: open the response in the Network tab, right-click the field's value and use "copy value". That copies all of it even when the long text is shortened on screen.
The most common mistake is copying only part of the code. Long text gets shortened on screen, or the selection doesn't reach the end. Where you can, use an option like "copy value", or save the code to a .txt file first.
2. Turn the code into an image
Open the Base64 to image tool and:
- Press "Or type / paste text", or just press Ctrl + V on the page. If the code is in a .txt file, choose the file.
- The picture is previewed straight away, with its type (PNG, JPG, SVG …), pixel size and file size underneath.
- Press Download image. The file is saved with the right extension for what is really inside.
If the code claims the wrong type (say the label is image/jpeg but it holds a PNG), the tool tells you and saves the file with the correct extension. All the decoding happens in your browser; nothing is uploaded.
3. Change the format if you need to
The decoded picture is saved in whatever format the code holds. If you need another one:
| You have | You want | Tool to use |
|---|---|---|
| WebP | JPG | WebP to JPG |
| SVG | PNG | SVG to PNG |
| PNG | JPG | PNG to JPG |
| Any image | JPG to PDF |
Common mistakes
The end of the code is missing. If the picture is half-drawn, grey or won't open at all, the code was most likely cut off. With JPG this shows up as a blank lower part. Copy the code again, in full.
Other text got mixed into the code. When copying from JSON, parts of neighbouring fields can end up in the selection. The tool strips quotes, spaces and line breaks itself, but it can't separate words that landed in the middle of the code.
The code isn't an image. Base64 is used for every kind of file. Code starting with data:application/pdf is a PDF; code starting with data:font/ is a font. These can't be saved as pictures.
Pasting the code into a site you don't trust. Base64 is not encryption — anyone who sees the code sees the picture. Decode code that carries personal documents, IDs or signatures only with a tool that runs in your browser.
To go the other way and put a picture inside HTML or CSS, see How to embed an image in HTML or CSS with Base64.
Ready to try it? It is free and your file stays on your device.
Open Base64 to image