Skip to main content

How to Convert Base64 to an Image File

Convert a Base64 string to an image in four steps: paste, preview, pick Original, PNG, JPG, or WebP, and download. Handles URL-safe strings and line breaks.

CompressMyPic Editorial Team · Published Nov 17, 2026 · 10 min read

How to Convert Base64 to an Image File

A Base64 string sits in your clipboard, your email, or an API response, and you need the picture it contains. The conversion takes about a minute once you know the steps.

This guide walks you through converting Base64 to an image in four steps: paste the string, review the preview, choose the download format, and save the file.

No software to install, no account to create, and nothing uploaded anywhere. The string is decoded locally in your browser from start to finish.

What You Need Before You Start

You need the Base64 string itself, copied in full. A truncated string cannot be decoded, so make sure the copy includes the beginning and the end.

Know what the image is for, because that decides the download format. Original keeps the file exact, PNG keeps transparency, JPG shrinks photographs, and WebP is the modern compact choice.

A browser is all the software you need. The tool runs on Chrome, Safari, Firefox, and Edge, on desktop and on mobile, with no extension.

If the string came wrapped in HTML or CSS, you can paste the whole thing. The decoder tolerates quotes and url() wrappers around the string.

Step 1: Paste the Base64 String

Open the Base64 to image decoder and paste the string into the input area. Decoding starts automatically, with no button to click.

The tool accepts strings with or without the data:image prefix. A full Data URL from a web page and a raw string from a JSON payload both work.

URL-safe strings work too. If the string uses dashes and underscores instead of plus and slash, the decoder recognizes the variant and decodes it correctly.

Line breaks and extra spaces are ignored. A string that was wrapped by an email client or pasted with surrounding whitespace still decodes without any cleanup.

Step 2: Review the Preview and Metrics

The decoded image appears on a checkerboard background, with its dimensions and file size shown beside it. Check that the picture is the one you expected.

Look at the checkerboard carefully. Gray and white squares showing through the image mean transparency, and that decides whether JPG is safe to use.

Check the dimensions. A small icon decoded from a string is a small image, and no download format will make it larger or sharper than it already is.

Check the binary file size. It should be about three quarters of the text length you pasted, because decoding removes the 33 percent encoding overhead.

Step 3: Choose the Download Format

Pick Original when you want the file exactly as it was encoded. This is the safest choice, especially for animated GIFs and vector SVGs, which lose their special properties when converted.

Pick PNG when the image has transparency or sharp edges. PNG preserves the pixels exactly and keeps the alpha channel, so logos and icons survive the round trip.

Pick JPG when the image is a photograph and you want the smallest file. JPG drops transparency, so only use it when the checkerboard preview shows no see-through areas.

Pick WebP when the destination is a modern website. It is smaller than PNG for most images and supports transparency, making it a good default for web use.

Step 4: Download the Image File

Click the download button. The file saves as decoded_image with the extension matching your chosen format, such as decoded_image.png or decoded_image.jpg.

Rename the file to something meaningful right away. A folder full of files called decoded_image is confusing, while a name like company-logo.png tells you what it is months later.

Open the downloaded file and confirm it looks right. The preview in the tool is reliable, but a final check of the actual file costs seconds and catches any misunderstanding.

If you need to encode the image again later, the image to Base64 encoder takes the downloaded file and produces a fresh string from it.

Decoding a String Without the Prefix

Many strings arrive without the data:image prefix, especially from APIs and databases. The decoder reads the image header to identify the format, so the missing prefix is not a problem.

Paste the raw string as it is. The tool detects whether the bytes describe a PNG, JPG, GIF, WebP, SVG, BMP, or ICO file, and shows the detected format beside the preview.

If the format is detected wrong, the file header itself is unusual. Download as Original in that case, and inspect the file with an image viewer before converting it.

When you share the string onwards, consider adding the prefix yourself. A Data URL is self-describing, and the next person who receives it will know the format without guessing.

Decoding a URL-Safe String

URL-safe Base64 replaces plus with a dash and slash with an underscore, so the string can sit inside a web address without being escaped. It looks almost identical to standard Base64.

The decoder accepts both alphabets without any setting to change. Paste the string and it decodes, regardless of which variant it uses.

If a string fails to decode, check for a mix of the two alphabets. A string that was partly converted, with some plus signs and some dashes, is damaged and needs a fresh copy from the source.

Padding can also be missing in URL-safe strings, because some systems strip the trailing equals signs. The decoder tolerates missing padding in most cases, but a complete string is always safer.

Decoding a String Wrapped in HTML or CSS

Strings are often copied with their surrounding code attached, such as an image tag with a Data URL source, or a CSS url() function wrapping the value.

You can paste the whole snippet. The decoder tolerates HTML quotes and CSS url() wrappers around the string, and it extracts the Base64 content from inside them.

If the paste fails, strip the wrapper yourself. Copy only the part between the comma after base64 and the closing quote, and paste that clean string instead.

For an HTML image tag, the string sits inside the src attribute after data:image/png;base64,. For CSS, it sits inside the url() parentheses, usually wrapped in quotes.

Converting an Old BMP or ICO String to WebP

Old favicon and bitmap strings decode into BMP or ICO files, which are bulky and poorly supported on the modern web. Converting them to WebP fixes both problems at once.

Paste the string, wait for the preview, and choose WebP as the download format. The tool converts the decoded image into a compact modern file.

Check the transparency first. An ICO favicon often has transparent areas, and WebP preserves them, so the converted icon looks the same as the original.

For a favicon specifically, consider downloading as PNG instead. Browsers accept PNG favicons widely, and the file is simpler to reference from your HTML.

Decoding an SVG String into a PNG File

An SVG Base64 string decodes into vector code, which is crisp at any size but not accepted everywhere. Some platforms want a raster image instead, and PNG is the usual choice.

Paste the string, confirm the preview shows the vector graphic correctly, and choose PNG as the download format. The tool renders the SVG into a PNG at its intrinsic dimensions.

The resulting PNG is a fixed-size image, so it will not scale like the original SVG. If the destination needs a large image, render at a larger size before downloading, or keep the SVG.

If the string is a plain SVG Data URL without the base64 marker, it will fail with an encoding error. That string is not Base64 at all, so save the SVG code directly as a file instead.

Troubleshooting Corrupt Strings

A string that fails to decode is usually truncated, altered, or never an image at all. The tool reports a clear error instead of producing a broken file.

Check the beginning and the end of the string first. Truncation usually cuts the tail, so a string that ends mid-word or without its padding is a sign of an incomplete copy.

Look for characters that do not belong in Base64. Angle brackets, quotes inside the string, or a URL with extra parameters all indicate that the copy picked up surrounding text.

When the source is an API response, check whether the response itself was cut short. A truncated JSON payload produces a truncated string, and only a fresh request can repair it.

Troubleshooting the SVG Encoding Error

The SVG encoding error appears when the pasted string is a plain SVG Data URL rather than a Base64 one. It contains readable SVG tags instead of encoded characters.

Recognize it by looking at the string. If you can read words like svg, path, or rect inside it, the string is URL-encoded SVG code, not Base64.

To get the file, copy the SVG code out of the Data URL, decode any percent escapes, and save the result as an .svg file in a text editor.

Do not try to force it through the decoder. The tool expects Base64 characters, and no setting will make it accept plain SVG markup as an encoded string.

Clearing the Input for the Next String

Long strings are awkward to delete by hand, so the tool provides a clear button that empties the input in one click. Use it between decodes to start fresh.

Clear before pasting the next string, not after. Pasting over a long string can leave fragments of the old one behind, which corrupts the new decode.

Download the current image before you clear. Clearing removes the string and the preview together, and the decoded image exists only as the downloaded file after that.

Working through a batch of strings is fast this way: paste, download, clear, and paste the next one, with no scrolling or manual selection in between.

Re-encoding the Downloaded Image

Sometimes the decoded image needs to go back into text form, for example after converting an old BMP to a modern WebP. The encoder handles that step.

Open the image to Base64 encoder, upload the downloaded file, and copy the fresh string in the output format you need.

The new string is shorter than the original when the conversion shrank the file. A BMP converted to WebP before re-encoding produces a dramatically shorter string than the original.

Keep both strings until you are sure the new one works. The original string is the only copy of the original file, and deleting it before testing is a needless risk.

Decoding Images from Chat Messages and Documents

Chat apps and collaboration tools sometimes expose images as Base64 strings in their message data, especially in bots, webhooks, and exported conversations. A copied payload can be decoded to recover the picture.

When you copy from a chat export, watch for the string being split across lines or wrapped in JSON escaping. Backslashes before slashes and quotes are escaping artifacts, not part of the string, and they must be removed before decoding.

Documents are a similar source. An exported Word or design file can contain an embedded image as a Base64 block inside its XML, and copying that block gives you the image directly.

The same truncation warning applies everywhere. A string copied from a message that was cut off mid-way will fail to decode, and the only fix is a complete copy from the source.

For large chat exports, decode one image at a time and rename each download immediately. A batch of files all called decoded_image is confusing, while names like team-photo-decoded.png stay useful.

Remember that a decoded image from a chat log may be a thumbnail rather than the original. Check the dimensions beside the preview before you assume the file is full resolution.

When the string comes from a system you control, consider changing the workflow to send files instead of strings. A file transfer is more efficient, and the Base64 round trip exists mainly for systems that cannot carry binary data.

When the string comes from a system you do not control, decoding is the only option, and this tool handles it locally without uploading the string anywhere.

Quick Reference Checklist

Paste the full string, check the preview and the checkerboard for transparency, choose Original, PNG, JPG, or WebP, and download as decoded_image with the right extension.

Clear the input between strings, rename downloads immediately, and keep the original string until the new file is tested.

For the full background, read the Base64 to Image: Complete Guide, and for the performance comparison, see Base64 vs Image Files: Performance and Use Cases.

Frequently asked questions

Can I decode a Base64 string on my phone?

Yes. The decoder runs in mobile browsers on iOS and Android. Paste the string, review the preview, and download the image. For very long strings, pasting can be slow, so use a shorter test string first to confirm the workflow.

What is the largest Base64 string I can decode?

There is no fixed limit in the tool, but very large strings take longer because the browser must parse all the text and rebuild the binary data. Multi-megabyte strings work, though they can be slow on older phones. If a string is too large to handle, ask the source for the image as a file instead.

Why does the decoded file have a different name than the original?

The Base64 string does not carry the original file name, so the tool cannot know it. Every download is named decoded_image with the matching extension. Rename the file right after downloading so your folders stay organized.

Can I decode a Base64 string that came from a PDF or Word document?

Only if the string itself is a valid Base64 image. Documents often store images in other forms, such as embedded binary data or compressed streams, which are not Base64. Extract the image from the document first, then encode or decode it as needed.

Does decoding a Base64 string reduce its quality?

No. Decoding is the exact reverse of encoding, so the bytes that come out are the bytes that went in. Any quality loss happened before the encoding, when the image was compressed or converted, and decoding cannot add to it or repair it.

What do I do if the string decodes but the image looks wrong?

First check whether you downloaded the right format. A transparent PNG downloaded as JPG gets its transparency filled, and an animated GIF converted to PNG loses its animation. Download as Original to see the true file, then decide on the conversion from there.

Related guides

Developer Tools

How to Extract a Colour Palette

Extract a colour palette from any photo in five steps: upload, pick 3–12 swatches, read the percentages, and copy CSS or JSON — free, in your browser.

Nov 17, 2026 · 10 min readRead the guide →

Share this guide

← Back to the blog