BrowserTools
Home / Encoders / Base64 to File, Decode and Download Any File

Base64 to File, Decode and Download Any File

Paste a Base64 string or data URI and download it as a real file. Detects PDF, PNG, JPEG, ZIP, DOCX and more automatically. Runs entirely in your browser.

Loading Base64 to File, Decode and Download Any File… If nothing happens, please enable JavaScript.

Base64 is how binary files travel through text-only channels. An API returns a PDF invoice as a long string, a database column stores an avatar as characters, a log line contains an attachment, a data URI embeds an icon in a stylesheet. At some point you need the file back, and a decoder that only prints text is useless: a decoded PNG shown as text is unreadable mojibake. This tool takes the Base64 and hands you the actual file, named and typed correctly, ready to open.

Frequently asked questions

Is my Base64 data uploaded to a server?
No. Decoding, type detection, preview and the download all happen inside your browser using the built-in atob function and the Blob API. The page makes no network request with your data, so the content never leaves your device. That is what makes it usable for confidential documents, certificates and private keys.
How does the tool know the file type and extension?
It reads the magic number, the fixed byte signature at the start of nearly every binary format: %PDF- for PDF, the 89 50 4E 47 sequence for PNG, FF D8 FF for JPEG, PK for ZIP, and so on. ZIP files are examined a little deeper, because DOCX, XLSX, PPTX and OpenDocument files are all ZIP containers that differ only in the entries they hold. If the bytes decode as valid UTF-8 text, it looks for JSON, XML, HTML or PEM structure instead.
Can I paste a full data URI?
Yes, that is the easiest case. Paste the whole thing, including the data:image/png;base64, prefix. The prefix is removed, the declared MIME type is used, and a name= parameter, if present, becomes the suggested filename. Detection still runs, and you get a warning if the declared type disagrees with what the bytes actually look like.
What if the detected type is wrong?
Override it. The filename, extension and MIME type are all editable fields, and once you edit one the tool stops overwriting it with its own guess. This matters for formats that share a signature, such as the many ZIP-based document formats, or for extensionless files where only you know the intended type.
Does it handle Base64url from a JWT?
Yes. The URL-safe alphabet, which replaces + with - and / with _, is converted back automatically, and missing = padding is restored. Note that a full JWT is three Base64url segments separated by dots, so paste only the segment you want to decode. To inspect a token properly, use the JWT decoder instead.
Why do I get an unexpected character error?
Something in the string is not part of the Base64 alphabet. The message names the character and its position so you can find it. Common causes are a truncated copy that clipped part of the string, a value that was HTML-escaped somewhere along the way (+ instead of +), or JSON escape sequences that survived the copy. Whitespace and newlines are not a problem, those are removed automatically.
Is there a size limit?
There is no fixed limit, only your device's memory. Base64 is about 33 % larger than the binary it encodes, and the decoder holds the string plus the decoded bytes at the same time, so a few hundred megabytes of Base64 can make a browser tab struggle, particularly on a phone. Files up to a few tens of megabytes decode comfortably.
The preview is blank but the download works. Why?
The preview relies on the browser being able to render that format. A PDF preview needs the browser's built-in PDF viewer, which some configurations disable, and a video preview needs a codec the browser supports. The decoded bytes are unaffected: if the download produces a file that opens correctly in a normal application, the decoding was fine.
Can it decode a Base64 string that is actually just text?
Yes, and it will tell you: the detected type comes back as text/plain, JSON or XML, and the content is shown in the preview pane so you can read it without downloading anything. If reading the text is all you need, the general Base64 encoder and decoder is the simpler page for that.
Why does the downloaded file open with the wrong application?
Operating systems pick applications by file extension, not by MIME type. If the extension field says bin because the format was not recognised, set the right one before downloading. Conversely, changing the extension does not convert anything: the bytes are whatever the Base64 encoded, and renaming a PNG to .jpg will not make it a JPEG.

About Base64 to File, Decode and Download Any File

Paste the string and the decoding happens as you type. You can paste a bare Base64 payload or a complete data URI such as data:application/pdf;base64,JVBERi0xLjQK, in which case the declared MIME type and any name parameter are picked up automatically. Line breaks, indentation, surrounding quotes and trailing commas left over from copying out of JSON or a code editor are stripped for you. Base64url, the URL-safe variant that uses - and _ instead of + and /, is accepted too, which matters because that is what JSON Web Tokens and many APIs produce, and missing padding is restored rather than treated as an error.

The interesting part is working out what the bytes actually are. The tool reads the file's magic number, the short signature at the start of almost every binary format, and recognises PDF, PNG, JPEG, GIF, WebP, BMP, ICO, TIFF, SVG, MP3, WAV, OGG, FLAC, MP4, WebM, ZIP, GZIP, RAR, 7z, WOFF and TrueType fonts, SQLite databases and Windows executables. ZIP containers are inspected one level deeper, so a DOCX, XLSX, PPTX or OpenDocument file is identified as such instead of a generic archive. When the content turns out to be valid UTF-8 text, it is classified further into JSON, XML, HTML, PEM or plain text. The suggested filename, extension and MIME type follow from that detection, and all three remain editable if you know better than the sniffer does.

Before downloading you can see what you decoded. Images, PDFs, audio and video are previewed inline, and text formats are shown as text, which is usually enough to confirm you pasted the right string. Everything runs locally: the decoding, the type detection and the preview all happen in your browser using atob and the File API, and the file is produced from an in-memory blob. Nothing is uploaded, which is what makes it safe for signed documents, private keys, medical records and anything else you would not paste into a server-side converter.

The 33 % Tax Everyone Agreed to Pay

Base64 exists because the early internet could not be trusted with the number 8. Many mail systems in the 1970s and 1980s were built on 7-bit ASCII, and some deliberately stripped the eighth bit or mangled control characters. Any byte above 127 could be silently destroyed in transit, which made sending a program or an image through email impossible. The workaround, formalised in RFC 989 in 1987 and refined in the MIME specifications of 1992, was to stop fighting the pipe: re-encode the data using only characters every system already handled safely, and accept the cost of doing so.

That cost is exactly 33 %, because 3 bytes of input (24 bits) become 4 characters of output (6 bits each). It is a strange bargain, paying a third more bandwidth for the privilege of using a dumber channel, and it was supposed to be temporary. Instead Base64 outlived the problem it solved. Modern email is 8-bit clean, yet attachments are still Base64 encoded, because by the time the transport improved, every mail client on earth had been built around the assumption.

The idea then spread far beyond email. Data URIs put Base64 images directly into HTML and CSS. JSON has no binary type, so every API that returns a file returns Base64. JWTs, TLS certificates in PEM form, SSH keys, PGP messages and Kubernetes secrets are all Base64 wrapped. That last one causes a recurring misunderstanding worth repeating: Base64 is not encryption. A Kubernetes secret stored as Base64 is readable by anyone who can run a decoder, which is to say anyone at all. Encoding hides data from a transport layer, not from a person.

Support