About the Base64 to Image Converter
Images are often embedded as long Base64 strings in HTML, CSS, JSON and API responses, which makes them impossible to view directly. Paste the string here and the Base64 to image converter decodes it in your browser, shows the picture with its format, pixel dimensions and file size, and lets you download it as an ordinary image file.
The file type is detected from the decoded bytes themselves, not only from the label, so PNG, JPG, GIF, WebP, BMP, ICO, AVIF, TIFF and SVG images are recognized even without a data URI prefix, and a mismatched label is pointed out. Line breaks, spaces and the URL-safe Base64 alphabet are handled automatically, and so is text wrapped in CSS url(…) or quotes.
If the text is not valid Base64, the exact character and position of the problem are shown, which makes it easy to spot a missing or extra character from a bad copy. The decoding happens entirely in your browser; nothing you paste is sent anywhere. It also works offline once the page has loaded.
To go the other way and turn a picture into Base64, use image to Base64. For Base64 that holds text rather than an image, try the Base64 decoder, and to change the format of the decoded picture, use the image converter.
How to use the Base64 to Image Converter
- Paste the Base64Paste a data URI or plain Base64 text into the box. Try the example to see how it works.
- Check the previewThe image appears with its type, dimensions, file size and Base64 length.
- Name the fileChange the file name if you like; the right extension is added for you.
- DownloadPress Download image to save the picture.
Base64 to Image Converter features
- Accepts data URIs and plain Base64
- Detects the real image type from the bytes
- PNG, JPG, GIF, WebP, BMP, ICO, AVIF, TIFF and SVG
- Handles line breaks and URL-safe Base64
- Exact position of invalid characters
- Shows dimensions and file size
- Download with the correct extension
- Nothing is uploaded
Common uses
- Saving images embedded in HTML or CSS files
- Viewing images returned by APIs in JSON
- Checking Base64 thumbnails stored in databases
- Extracting inline images from email source code
- Debugging data URIs in web pages
Base64 to image: decoding data URIs back into files
Base64 strings that represent images turn up in many places: website source code, CSS files, API responses, email source, browser developer tools and database fields. They look like a long run of random letters, but they are simply image files written as text. Decoding a Base64 string turns it back into a picture you can view and save. This guide explains how to recognise image Base64, how decoding works and how to fix strings that refuse to decode.
Recognising an image data URI
The clearest sign is a data URI prefix:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...
The part between data: and ;base64 names the image type. Even without the prefix, the first characters often reveal the format:
| Starts with | Format |
|---|---|
| iVBORw0KGgo | PNG |
| /9j/ | JPEG |
| R0lGOD | GIF |
| UklGR | WebP |
| PHN2Zy or PD94bW | SVG (XML text) |
These patterns come from the "magic numbers" at the start of each file type, encoded in Base64.
How decoding works
Base64 maps every four characters back to three bytes. The decoder converts the text to bytes, and those bytes are the image file exactly as it was before encoding. Nothing is lost or changed: a PNG encoded and decoded is bit-for-bit identical.
Why a string may fail to decode
Missing characters. Long strings copied from logs or terminals are often cut off. A truncated string decodes to a broken image, usually missing its bottom part or failing entirely.
Extra characters. Quotes, commas, backslashes and line breaks copied with the string can break decoding. Remove anything before data: and after the last Base64 character.
URL-safe Base64. Some systems use - and _ instead of + and /. A decoder that expects standard Base64 may reject these; replacing them fixes the problem.
Escaped strings. JSON may store slashes as \/. Unescape the string first, which JSON Escape can help with.
A worked example: rescuing an image from an API response
A developer receives a JSON response with an avatar field containing a long Base64 string and wants to see the image. Copy the value between the quotes, without the quotes themselves. Paste it here; the preview shows a small profile picture and identifies it as JPEG, 18 KB. If the preview is broken, check the end of the string: JSON viewers sometimes shorten long values for display, so copy the value from the raw response instead. Once it decodes, download the file with a .jpg extension.
Checking the size
Base64 text is about a third larger than the file it represents. A 40,000-character string decodes to roughly 30 KB. If the decoded size is much smaller than expected, the string was probably truncated.
Security considerations
Images from unknown sources should be handled with care. Decoding in your browser and viewing the result is generally safe, because browsers render images in a protected way. SVG images can contain scripts, though, so do not embed decoded SVGs from untrusted sources directly into your own web pages without checking them.
Going the other way
To turn an image into Base64 for embedding in code, use Image to Base64 Converter. For non-image Base64, such as text or JSON, Base64 Decoder decodes to readable text.
Saving with the right extension
Save the decoded image with the extension matching its type: .png, .jpg, .gif, .webp or .svg. A wrong extension can stop some programs from opening the file even though the data is fine.
Quick checklist
- Copy the full string, nothing more, nothing less.
- Check the prefix or first characters for the format.
- Compare the decoded size with what you expected.
- Save with the correct file extension.
Where Base64 images hide in everyday work
Web developers meet Base64 images in stylesheets, where small icons are embedded as data URIs, and in HTML emails, where logos are sometimes embedded so they display offline. Support teams see them in exported chat logs and form submissions, where uploaded screenshots are stored as text. Data analysts find them in database columns and spreadsheets exported from web apps. In each case, decoding the string is the fastest way to see what the image actually is, without writing any code.
Decoding many strings
If you have a list of Base64 images, for example from a CSV export, decode them one at a time and save each with a meaningful name, such as the record's ID. Keeping names linked to the source records makes it easy to match each image back to the right customer or product later.
Telling apart image and non-image Base64
Not every Base64 string is a picture. Encoded text, JSON, certificates and compressed archives look just as random. If the preview fails and the string does not start with one of the image patterns above, try decoding it as text instead; readable words or curly braces mean it was never an image in the first place, and the right tool is a text decoder rather than this one.
Privacy
Decoding happens in your browser. The Base64 text and the resulting image never leave your device, which matters when they come from private systems or customer data.
Frequently asked questions
How do I convert Base64 to an image?
Paste the Base64 text or the complete data URI into the box. The image is decoded and shown at once, with its type and size. Press Download image to save it as a PNG, JPG or whichever format the data contains.
Do I need the data:image prefix?
No. The tool accepts both a full data URI and the bare Base64 characters. Without a prefix, the image type is worked out from the first bytes of the decoded data, which identify every common image format.
Why does it say my Base64 is invalid?
Base64 uses only letters, digits, plus, slash and equals signs, or minus and underscore in the URL-safe variant. Any other character usually comes from a bad copy, such as a cut-off line, an ellipsis or a stray quote. The message shows exactly which character and where.
What image formats are supported?
PNG, JPG, GIF, WebP, BMP, ICO, AVIF, TIFF and SVG are recognized. All of them can be downloaded; the preview shows whatever your browser can display, which includes everything except TIFF in most browsers.
Why is Base64 bigger than the image file?
Base64 stores every 3 bytes as 4 text characters, so the text is about 33 percent larger than the file it encodes, plus any line breaks. Decoding it gives back the original, smaller binary file.
Can I decode a Base64 SVG?
Yes. Both Base64-encoded SVG and the percent-encoded form used in CSS data URIs, such as data:image/svg+xml,%3Csvg…, are decoded, previewed and saved as an .svg file.
Is my data sent anywhere?
No. The Base64 text is decoded by code running in this page on your own device, and nothing is uploaded or stored. It is safe for private images and API data.