Skip to content
ToolPlankDEV
Encoders & Decoders
100% In-Browser Execution

Updated:

Base64 to File Converter

Paste a Base64 string or a data URI and download the real file. This base64 to file converter reads the first bytes to find the file type, shows the size and a SHA-256 hash, previews images, audio, video and text, and warns about programs. Nothing is uploaded.

Processing in browser...

Loading the tool. It runs entirely in your browser, so your data is never uploaded.

More free tools you may need next.

Quick Guide

How to use Base64 to File

Simple step-by-step instructions to get the exact output you need.

  1. 01

    Add your Base64

    Paste a Base64 string or a data URI into the left box, press Paste, or open a .txt file that holds it. Example loads a small PNG so you can see the result first.

  2. 02

    Check the detected file

    The right panel names the file type, found from the first bytes of the decoded data. It also shows the size, a suggested file name, a SHA-256 hash and a preview for images, audio, video and text.

  3. 03

    Name the file if you like

    The suggested name uses the right extension for the detected type. Type your own name in the File name box to change the part before the extension.

  4. 04

    Download the file

    Press Download file to save the decoded bytes. Swap sends the file to File to Base64 so you can check that it encodes back to the same text.

How to convert Base64 to a file

A Base64 string is a file written in 64 plain characters. To convert base64 to file, the tool turns every four characters back into three bytes, finds out what kind of file those bytes make, and gives you a download with a fitting name.

The built-in example decodes to a 96 by 64 pixel PNG of 16,607 bytes. The panel reports PNG image, shows the picture, and names the file gradient.png. Its SHA-256 hash begins 426a243b7751fb5b.

How the file type is found

Most file formats start with a fixed signature. The tool checks it, so the type is correct even when the string has no label. It knows PDF, PNG, JPEG, GIF, WebP, AVIF, BMP and ICO images, SVG, MP3, WAV, Ogg, FLAC, M4A, MP4, MOV and WebM media, WOFF, TrueType and OpenType fonts, ZIP, GZIP, BZIP2, 7-Zip, RAR and TAR archives, Word, Excel and PowerPoint files, SQLite databases, programs, and plain text, JSON, HTML, XML and scripts.

A data URI states a type of its own, as in data:image/png;base64,.... The tool compares it with the bytes. If they disagree, a warning appears and the file is named after the bytes, because those are what the file really is.

What this Base64 decoder accepts

  • Plain Base64, with or without line breaks and spaces, including the 76-character lines used in email.
  • Data URIs. The text before the comma is read and removed.
  • URL-safe Base64, which uses - and _ in place of + and /.
  • Text with missing = padding. The padding is added and the panel says so.
  • Percent-escaped characters such as %2B and %3D, and JSON escapes such as \/.
  • A JSON object or array. The longest text value in it is decoded, and the panel names the field.

Anything else, such as a stray character or a string that is too short, gives an error with the position and what to check.

Why a decoded file will not open

  • The string was cut off when it was copied. A length that does not fit Base64 is reported, but a cut that falls on a boundary gives a smaller file that looks fine until you open it. Compare the size with what you expect.
  • The text was encoded twice. If the decoded result is plain text that itself looks like Base64, paste that text in again.
  • It was a different type of file than you assumed. The detected type line tells you what the bytes are.
  • A Word, Excel or PowerPoint file is a ZIP inside. The tool names it by looking for the parts Office files contain.

To compare with the original, ask the sender for its SHA-256 hash. If your hash is the same, the decoded file is identical.

Programs and other risky files

A decoded file can be anything, including a program. The tool never opens or runs the result. Windows and Linux programs, macOS binaries, Java archives, Android packages and scripts that start with #! are marked with a warning. HTML and SVG can hold scripts too, so open a downloaded .html file only if you trust it. Only run a program if you trust where the text came from.

Images, audio and video are shown with your browser's own players, and text is shown as plain text. For a PDF, Base64 to PDF shows the page count and checks for encryption and scripts, and for pictures Base64 to Image adds more image tools. To decode Base64 that is only text, use Base64 Decode.

Base64 to file on the command line and in code

Bash
base64 --decode report.b64 > report.docx      # Linux
base64 -D -i report.b64 -o report.docx        # macOS
powershell
[IO.File]::WriteAllBytes("report.docx", [Convert]::FromBase64String((Get-Content report.b64 -Raw)))
JavaScript
require("fs").writeFileSync("report.docx", Buffer.from(text, "base64"));

To make Base64 from a file, use File to Base64.

Limits and privacy

  • Up to 15 million characters of input and 10 MB of decoded data.
  • Previews are for images, audio, video and text. Other types download without a preview.
  • The file type comes from the bytes. Files with no recognizable signature are shown as unknown binary data.

The text is decoded in your browser. It is not uploaded or stored. See the Privacy Policy for details.

Frequently Asked Questions

Technical Q&A for Base64 to File

Common questions about edge cases, character encoding, and privacy guarantees.

Paste the Base64 string or data URI into the left box. The tool decodes it, names the file type and shows a preview. Press Download file to save it.

The tool reads the first bytes of the decoded data, which identify most formats. The detected type and the file name extension are shown in the right panel.

The string may be cut off, encoded twice, or a different type than you expected. Check the size and the detected type, and compare the SHA-256 hash with the sender's.

Yes. Data URIs, URL-safe text with - and _, text with line breaks and text with missing padding all work. The panel lists the fixes it made.

Up to 15 million characters of input and 10 MB of decoded data. For bigger files, use a command line tool such as base64 --decode.

No. The text is decoded in your browser and nothing is sent to a server.

Decoding is safe because the tool never opens or runs the file. Opening it afterward is up to you, and programs are marked with a warning.

In Node use fs.writeFileSync(name, Buffer.from(text, "base64")). In PowerShell use [IO.File]::WriteAllBytes(name, [Convert]::FromBase64String(text)).

Yes. ZIP archives and Word, Excel and PowerPoint files are recognized and named with the right extension.

Yes. Type a name in the File name box. The extension still follows the detected type, so a PNG always ends in .png.