Base64 to File Converter

Paste a Base64 string or a data URI to rebuild the original file. The tool recognizes the format from its first bytes, shows a preview when it can, and saves it with the right extension.

Runs entirely in your browser. Nothing is uploaded.

How to use

  1. Paste the Base64 string or the complete data URI into the input box. Spaces and line breaks do not matter.
  2. Check the detected file type and size. Images, PDFs, audio, video and text are shown in a preview.
  3. Download the file. It is saved with a name and extension that match the detected type.

How the file type is detected

Base64 text carries bytes, not a file name. Unless you paste a data URI with a MIME type, nothing in the string says whether it holds a PDF, a ZIP archive or a sound. The tool therefore decodes the data and inspects the first few bytes, the file signature or "magic bytes" that most formats place at the very start. Because those bytes are fixed, the Base64 text of each format also starts in a recognizable way:

FormatFirst bytesBase64 starts with
PDF%PDFJVBER
PNG89 50 4E 47iVBORw0KGgo
JPEGFF D8 FF/9j/
GIFGIF8R0lGOD
ZIP (also DOCX, XLSX, JAR)PK 03 04UEsDB
MP3 with ID3 tagID3SUQz
WAV, WebP, AVI (RIFF)RIFFUklGR

When the decoded file will not open

Base64 decoding is lossless, so a broken file almost always means the input was not what you expected. Check these causes in order:

  • Truncated input. Log files, terminals, spreadsheet cells and chat apps often cut long strings. Missing text at the end gives a file that is too short, and most formats then refuse to open. If you know the original size, compare it with the decoded size.
  • Extra characters. Quotes, commas or a field name copied along with the value, or escape sequences such as \/ and \n from a JSON string, are not part of Base64. Copy only the value itself.
  • A different encoding or variant. Hex, Base32, Base85 or a custom alphabet can look similar at a glance but turn into garbage when decoded as Base64. The Base Detector tries every decoder and shows which one fits.
  • Not a file at all. If the result is detected as plain text, the string was Base64 of text: JSON, a token, or another layer of Base64. Read it with the Base64 decoder, and decode once more if the output is Base64 again.

The Base64 Validator lists invalid characters with their positions and reports padding problems, which helps to locate a damaged section.

Decode Base64 to a file in code

# Python
import base64
with open('output.bin', 'wb') as f:
    f.write(base64.b64decode(data))

// Node.js
fs.writeFileSync('output.bin', Buffer.from(data, 'base64'));

# Linux
base64 -d input.txt > output.bin

# macOS
base64 -D -i input.txt -o output.bin

# Windows PowerShell
[IO.File]::WriteAllBytes("C:\files\output.bin", [Convert]::FromBase64String((Get-Content input.txt -Raw)))

Frequently asked questions

Which file types can be detected?

Common formats with a clear signature: PDF, ZIP, GZIP, 7z and RAR archives; PNG, JPEG, GIF, WebP and other images; MP3, WAV, OGG, FLAC and M4A audio; MP4 and WebM video; WOFF, WOFF2, TTF and OTF fonts; WebAssembly and more. JSON, XML, HTML and plain text are recognized too. Formats without a signature cannot be identified, so if you know the real type, rename the downloaded file.

Why was my Word or Excel file detected as ZIP?

DOCX, XLSX and PPTX files, like EPUB and JAR, are ZIP archives with a particular folder structure inside, and they start with the same magic bytes as any ZIP file. The decoded bytes are correct: rename the download to .docx, .xlsx or whatever extension you need and it will open normally.

Can I paste a data URI?
Yes. Paste the complete string, including the data:...;base64, prefix, or paste only the Base64 part. Either way the type is checked against the decoded bytes.
Why is the decoded file smaller than the Base64 text?

Base64 uses 4 characters for every 3 bytes, so the file is about three quarters of the length of the text. If it is much smaller than the file you expected, the input was probably cut off.

Is my data sent anywhere?

No. Decoding, type detection and the preview all run in your browser, and the download is created on your device. Nothing is uploaded.