Base64 Encode/Decode

Base64 to File Converter: Decode Base64 to Any File

Decode a Base64 string to a downloadable file. Auto-detects format from content signature. Works with images, PDFs, audio, and any binary file. Client-side.

100% client-side. Your data never leaves your browser.

Related Tools

Decode Base64 to Any File

Paste a Base64 encoded string to decode it into a downloadable file. This tool auto detects the file format from content signatures and works with images, PDFs, audio, archives, and any binary data. The entire process runs in your browser.

How to Use

  1. Switch to the “Base64 to File” tab above
  2. Paste a Base64 string or data URI
  3. The tool detects the file type and shows details (MIME type, size, extension)
  4. Click Download to save the file

File Format Detection

This tool identifies files by their magic bytes, the signature bytes that begin every file of a particular type:

SignatureBase64 prefixDetected as
\x89PNG\r\n\x1a\niVBORPNG image
\xFF\xD8\xFF/9j/JPEG image
GIF89a or GIF87aR0lGODGIF image
RIFF....WEBPUklGRWebP image
<svgPHN2ZySVG image
%PDFJVBERiPDF document
PK\x03\x04UEsDBZIP archive
ID3SUQzMP3 audio

If a data URI is provided, the MIME type from the URI takes precedence. For unrecognized signatures, the file is saved with a .bin extension.

Common Sources of Base64 Encoded Files

API responses

Many web APIs return binary data as Base64 strings in JSON:

{
  "result": "UEsDBBQAAAAIAM1Y...",
  "type": "application/zip"
}

AI APIs (image generation, text to speech), document generation services, and chart rendering APIs commonly use this pattern.

Database exports

When applications store binary files as text in databases, exported records contain Base64 encoded data that needs to be decoded to recover the original files.

Configuration files

Kubernetes secrets, CI/CD pipelines, and cloud configuration store binary data (TLS certificates, private keys, license files) as Base64:

apiVersion: v1
kind: Secret
data:
  tls.crt: LS0tLS1CRUdJTi...
  tls.key: LS0tLS1CRUdJTi...

Email source

MIME encoded email attachments appear as Base64 blocks in raw email source, between boundary markers.

Decoding in Different Languages

JavaScript (browser)

function base64ToFile(base64, filename) {
  const binary = atob(base64);
  const bytes = new Uint8Array(binary.length);
  for (let i = 0; i < binary.length; i++) {
    bytes[i] = binary.charCodeAt(i);
  }
  return new File([bytes], filename);
}

JavaScript (Node.js)

const fs = require('fs');
const buffer = Buffer.from(base64String, 'base64');
fs.writeFileSync('output.bin', buffer);

Python

import base64

data = base64.b64decode(base64_string)
with open('output.bin', 'wb') as f:
    f.write(data)

Go

data, err := base64.StdEncoding.DecodeString(base64String)
os.WriteFile("output.bin", data, 0644)

Bash

base64 -d < encoded.txt > output.bin    # Linux
base64 -D < encoded.txt > output.bin    # macOS

Handling Data URIs

Data URIs include the MIME type before the Base64 content:

data:application/pdf;base64,JVBERi0xLjQK...

This tool handles both formats. If you paste a data URI, it strips the prefix and uses the declared MIME type. If you paste raw Base64, it detects the type from the content signature.

To strip the prefix programmatically:

const base64 = dataUri.split(',')[1];
const mimeType = dataUri.match(/data:([^;]+)/)[1];

Size and Performance

Browser based Base64 decoding works reliably for files up to tens of megabytes. This tool caps input at 50 MB to prevent memory issues. The decoded file size is approximately 75% of the Base64 string length (the inverse of the 33% encoding overhead).

For type specific tools, see Base64 to Image and Base64 to PDF. For the reverse operation, see File to Base64 or the general Image to Base64 converter.