Guides / Image guides
How to Convert Base64 Text to an Image
To convert Base64 text to an image, paste it into Base64 to Image, select Convert to image, check the preview and download the file. It accepts either the bare Base64 string or a full data URI that starts with data:image/png;base64,. The text is decoded in your browser, so a private image never has to be sent to a website.
What Base64 image text looks like
Base64 is a way of writing binary data, such as the bytes of a picture, using only letters, digits, plus, slash and equals signs. It lets an image travel inside places that only handle text: a JSON response from an API, an HTML page, a stylesheet, an email or a database field. If you want the background on the format itself, Base64 encoding explained covers it.
You will meet image Base64 in two forms.
- A raw Base64 string. A long run of characters, often thousands of them, with nothing to say what it is. A PNG one starts
iVBORw0KGgo. - A data URI. The same string with a label in front, such as
data:image/jpeg;base64,/9j/4AAQ.... The label tells a browser what the data is, which is why you can paste a data URI straight into an image tag.
The first few characters often reveal the type. A JPG commonly begins /9j/, a PNG iVBORw0KGgo, a GIF R0lGOD and a WebP UklGR. A PDF begins JVBERi0, which is a handy clue when something you expected to be a picture turns out to be a document.
How to convert it, step by step
- Open Base64 to Image.
- Paste the text into the box. You can paste the plain string or the whole data URI. Line breaks and spaces are ignored, so text that was wrapped over several lines is fine.
- Select Convert to image.
- Look at the preview. Underneath, the tool reports the detected type, the pixel size and the file size.
- Select the Download button to save the file. It is named
imagewith the right extension for what was found.
If you want to start again, use Clear. Because the work is done in the page, nothing leaves your device, which matters when the image is a signature, an identity document or a screenshot from a customer.
How the tool decides the file type
A data URI carries a label, but labels can be wrong. A developer may have written image/png for a file that is really a JPG. The tool does not rely on the label. It looks at the first bytes of the decoded data, which identify the real format, and it recognises JPG, PNG, GIF, WebP, BMP, AVIF, ICO and SVG.
The download is named to match what it found. If the label and the content disagree, a note in the result says so, for example that the header said one type but the content is another, so it was saved with the extension of the real one. That avoids the common annoyance of a file with a .png ending that nothing will open.
The preview is drawn on a light checkerboard, so transparent areas in a PNG, GIF or WebP are easy to tell from white. Once you have the file you can change its format, and how to convert PNG to JPG explains when that makes sense.
Fixing common errors
Most failures come from copying more or less text than you should. The tool gives a plain message for each case.
A character that is not valid in Base64
Base64 uses letters, digits, plus, slash and equals only. A quotation mark, comma or bracket at the end usually means you copied part of the surrounding code. The tool removes a single quote mark at each end, but anything else needs to be deleted by hand. Another cause is a backslash. Inside JSON, slashes are sometimes escaped as \/, and you should take the backslashes out before pasting.
Percent signs in the text
If the string came from a web address, plus signs and equals signs may have been percent-encoded as %2B and %3D. Decode it first with URL Encode and Decode, which is explained in URL encoding explained. Be careful with a plus sign that was turned into a space in a query string. Because spaces are ignored, the data would be damaged without any warning, so put the plus signs back before you decode.
The text looks cut off
A valid Base64 string cannot have a length that leaves one character over after counting in groups of four. When it does, the tool tells you that the text looks cut off and asks you to copy the whole string. Long values are easily truncated by a terminal, a spreadsheet cell or a chat message.
Equals signs in the middle
Equals signs are padding and may only appear at the very end. If they appear earlier, two strings have probably been joined together. Split them and convert each one separately.
This data URI is not Base64
Some data URIs, especially SVG ones, hold plain percent-encoded text and have no ;base64 part. The tool only handles Base64 data URIs and says so. For an SVG written like that, the quickest route is to save the markup in a text file with an .svg ending.
When it decodes but is not an image
Valid Base64 is not always a picture. If the decoded bytes do not start like a known image, you are told so rather than shown a broken preview. Two cases are named specifically. A PDF is reported as a PDF document, and a ZIP or Office file is reported as such. Anything else is described as data that does not start like a known image.
The most frequent reason is that the Base64 is of plain text, such as a JSON message or a token, and not of a file. For that, Base64 Encode and Decode will show you the text. There is also the opposite problem, where the data is an image but it is damaged. The tool may report the right type by its first bytes while your browser cannot display it. That usually means the string was truncated or altered in transit.
Going the other way: image to Base64
If you need to produce this text instead, Image to Base64 reads a JPG, PNG, WebP, GIF or SVG file and gives you two boxes: the raw Base64 and the full data URI. Copy whichever you need, or download it as a text file.
Be aware of the size cost. Base64 stores three bytes as four characters, so the text is about a third larger than the file. That is acceptable for a small icon or a logo, but a poor choice for a large photograph, since the image can no longer be cached separately and it makes the page heavier. If you do inline an image, make it small first. How to compress images without losing quality and how to resize an image both help.
Where to find the Base64 text in the first place
Knowing where the string lives makes copying it cleanly much easier.
- In a web page. Open the page source or your browser’s inspector, find the image tag, and copy everything inside the quotation marks after
src=. That gives you a data URI. - In a stylesheet. Look for
url(data:image/...)and copy what is between the brackets, leaving out the brackets themselves. - In an API response. Fields with names such as image, photo, avatar or signature often hold Base64. Copy only the value, without the quotes or the comma that follows it.
- In an email source. Inline attachments appear as long blocks of wrapped lines. Copy the block and paste it as it is, since the line breaks are ignored.
If you are not sure whether a very long string is complete, compare its ending with the source. A correct image string often finishes with one or two equals signs, though some do not, so treat that only as a hint.
Practical tips
- Keep the original source. Base64 is a copy of the file. If you can get the original image from where it was stored, that is better than a decoded one.
- One image at a time. The tool decodes a single pasted value. If an API response holds several, convert them one by one.
- Check the dimensions. The result shows the pixel size, so you can tell a thumbnail from a full image straight away.
- Treat unknown text with care. Decoding only turns text into a picture. It does not check that the picture is safe or that you are allowed to use it.
- Very long strings. Pasting a few megabytes of text into a page can be slow on an older phone. A desktop browser copes better.
Base64 to Image does not edit pictures. It decodes, previews and saves, and anything further is done with the other tools on this site.
Frequently asked questions
Do I need the data: prefix to convert Base64 to an image?
No. Both a plain Base64 string and a full data URI work. Line breaks and spaces in the pasted text are ignored.
Is the Base64 text uploaded anywhere?
No. It is decoded in your browser and never sent to a server, so private images stay on your device.
How does the tool know whether it is a JPG or a PNG?
It reads the first bytes of the decoded data, which identify the real format, and does not trust the label in the data URI. If they disagree, the file is saved with the extension of the real type.
Which image formats can it recognise?
JPG, PNG, GIF, WebP, BMP, AVIF, ICO and SVG. A PDF or ZIP is recognised too, but it is reported as not being an image.
Why do I get an error about an invalid character?
Base64 only uses letters, digits, plus, slash and equals signs. A quote, comma, bracket or backslash usually means extra text was copied along with the data.
Why does it say the text looks cut off?
The length of the string cannot be a valid Base64 length, which almost always means part of it is missing. Copy the whole value again.
Why is Base64 bigger than the original image?
Base64 writes every 3 bytes as 4 characters, so the text is about 33 percent larger than the file. Use it for small icons and avoid it for large photos.