Choose language

Base64 to File Converter

Decode any Base64 string back into a downloadable file. Detects the MIME type, sets the right extension, and works with data URIs and raw strings.

Mehmet Demiray Published Updated
Share
Name for the downloaded file; the extension is added from the detected type

What Base64 to File Does

Base64 is a way of writing binary data using only plain text characters, which lets files travel safely inside emails, JSON payloads, HTML, and config files. The catch is that a Base64 string is not usable on its own. You cannot open it in an image viewer or attach it to a message until it has been turned back into the original bytes. This tool reverses the encoding. You paste a Base64 string, and it rebuilds the exact file the string represents, ready to download. The conversion is lossless, so the result is byte-for-byte identical to the source file that was originally encoded. That matters for images, PDFs, archives, and any format where a single altered byte would break the file. If you only need the text representation going the other way, the File to Base64 tool encodes a file into a Base64 string instead. The pairing covers both directions of the same workflow.

Data URIs and Raw Strings

Base64 shows up in two common shapes. A raw string is just the encoded characters with nothing attached. A data URI wraps that string with a prefix that names the file type, like data:image/png;base64, followed by the payload. Both are valid inputs here. When you paste a full data URI, the prefix is read to learn the MIME type, so the decoded file gets the correct extension automatically. When you paste a raw string with no prefix, there is no type information inside it, so the tool inspects the first decoded bytes to guess the format. This signature check recognises common types such as PNG, JPEG, PDF, and ZIP by their magic numbers. If you already know what the data should be, you can confirm or override the detected type before downloading. Keeping the data URI prefix intact when you have it gives the most reliable result.

Detecting the File Type

The extension on a file is not stored inside the Base64 string, so the converter has to work out what kind of file you are decoding. The most reliable source is a data URI prefix, which states the MIME type directly. When that is missing, the tool falls back to signature detection, reading the opening bytes of the decoded data and matching them against known patterns. Here are a few examples of those leading bytes:

Format First bytes Extension
PNG 89 50 4E 47 .png
JPEG FF D8 FF .jpg
PDF 25 50 44 46 .pdf
ZIP 50 4B 03 04 .zip

If the format cannot be identified, the file is saved with a generic extension that you can rename. For a deeper look at how a byte signature maps to a content type, the MIME Type Checker tool inspects the same magic numbers.

Common Uses for Decoding

Decoding Base64 back into files comes up constantly in development and support work. API responses sometimes return documents or images as Base64 fields, and you need the actual file to inspect or test it. Email systems store attachments as Base64 inside the raw message, so pulling a string out and decoding it recovers the original attachment. Front-end code often embeds small icons as data URIs, and extracting one lets you save it as a standalone asset. Configuration files and tokens occasionally carry Base64 blobs that turn out to be certificates or keys. In each case the workflow is the same: copy the encoded text, paste it here, and download the rebuilt file. Because everything stays text until the final step, Base64 is a convenient transport format, and this tool is the step that makes the payload usable again once it arrives.

Encode and Decode Round Trips

Encoding and decoding are two halves of one loop, and it helps to know which tool handles which direction. To turn a file into text, you encode it, producing a Base64 string you can paste anywhere plain text is accepted. To turn that text back into a file, you decode it, which is what this tool does. If you only have the raw string and want to read it as text rather than rebuild a binary file, the Base64 Decode tool handles plain string decoding without forcing a download. A useful sanity check is the round trip: take a file, encode it, then decode the result and confirm the output matches the original. Because Base64 is lossless, a correct round trip always returns identical bytes. If the decoded file is corrupt, the problem is almost always a truncated or modified string rather than the conversion itself.

The ones we answer the most.

Can I paste a full data URI or only the raw Base64?

Both work. If you paste a complete data URI like data:application/pdf;base64,..., the prefix tells the tool the exact file type and the download gets the right extension. If you paste only the raw encoded characters, the tool inspects the decoded bytes to guess the format instead.

How does the tool know what file extension to use?

It first looks for a MIME type in a data URI prefix, which is the most reliable source. When that is missing, it reads the opening bytes of the decoded data and matches them against known signatures for formats such as PNG, JPEG, PDF, and ZIP. If nothing matches, the file is saved with a generic extension that you can rename.

Why is my decoded file corrupt or won't open?

The most common cause is an incomplete string. If even a few characters were cut off during copying, the decoded bytes will not match the original and the file breaks. Make sure you copied the entire string, including any trailing padding characters, and that no line breaks were accidentally inserted into the middle of the data.

Is there a limit to the file size I can decode?

Decoding happens in your browser, so the practical limit is your device memory rather than a server quota. Small images, documents, and text files decode instantly. Very large files can be slow because the whole Base64 string has to be held in memory and converted at once, so multi-megabyte strings may take a moment.

What is the difference between this and a Base64 string decoder?

This tool rebuilds a binary file and offers it as a download, which is what you want for images, PDFs, and archives. A plain string decoder like Base64 Decode returns the decoded content as readable text, which is better when the original data was just text and you do not need a file at all.

Can I convert a file back into Base64 here?

Not with this tool, which only goes from Base64 to a file. To go the other way and turn a file into a Base64 string, use the File to Base64 tool. The two cover opposite directions of the same workflow, so you can move freely between a file and its encoded text.