Home › Developer Tools › Base64 to File

Base64 to File

Paste any Base64 string or data URI to turn it back into a real file. The tool reads the file signature (magic bytes) to name it correctly, previews images, PDFs, audio, video, text and ZIP contents, and lets you download it in one click, all in your browser.

Last updated:

0 characters
Decoded file
Paste Base64 on the left to see the decoded file here
File type
-
MIME type
-
File size
-
SHA-256
-

Decoding happens in your browser: the Base64 text and the decoded file are never uploaded. Opening a decoded file runs nothing; executables are only saved, not started.

Advertisement
Advertisement

How to use the Base64 to File

  1. Paste the Base64 (with or without a data:…;base64, prefix) into the left box, open a .txt file that contains it, or try a sample.
  2. Let it decode: the result appears instantly; press Decode Base64 if you turned off typing.
  3. Check the detected type, size and SHA-256, and look at the preview or the Hex tab.
  4. Adjust the file name if you like; the extension follows the detected type.
  5. Download the file or open it in a new tab.

Common file signatures (magic bytes)

These are the first bytes the decoder looks for. The Base64 column shows how each signature begins once encoded, which lets you guess a file type just by looking at the start of a Base64 string:

File typeFirst bytes (hex)Base64 starts withMIME type
PDF25 50 44 46 (%PDF)JVBERiapplication/pdf
PNG89 50 4E 47 0D 0A 1A 0AiVBORw0KGgoimage/png
JPEGFF D8 FF/9j/image/jpeg
GIF47 49 46 38 (GIF8)R0lGODimage/gif
WebP / WAV / AVI52 49 46 46 (RIFF)UklGRimage/webp, audio/wav, video/x-msvideo
ZIP, DOCX, XLSX, PPTX, EPUB, JAR50 4B 03 04 (PK)UEsDBapplication/zip and Office types
MP3 with ID3 tag49 44 33 (ID3)SUQzaudio/mpeg
MP4 / MOV / M4A?? ?? ?? ?? 66 74 79 70 (ftyp at offset 4)AAAAIGZ0eXA, AAAAGGZ0eXA…video/mp4, video/quicktime, audio/mp4
GZIP1F 8BH4sIapplication/gzip
Windows EXE / DLL4D 5A (MZ)TVqapplication/vnd.microsoft.portable-executable
WOFF2 font77 4F 46 32 (wOF2)d09GMgfont/woff2
JSON text7B ({)eyapplication/json

Where Base64 files usually come from

  • API responses: many APIs return documents, signatures, labels and receipts as a Base64 field inside JSON. Paste the whole JSON object: the tool picks the longest Base64 value automatically.
  • Email (MIME): attachments are Base64 with line breaks every 76 characters. Copy the block between the part headers; the line breaks are ignored.
  • Data URIs in HTML, CSS or browser dev tools: data:font/woff2;base64,… and similar. The declared type is checked against the real bytes.
  • JWTs and URLs use URL-safe Base64 (- and _ instead of + and /, often without padding), which is converted automatically.

Going the other way? File to Base64 encodes any file. For images and PDFs specifically, Base64 to Image and Base64 to PDF offer format-specific extras.

Frequently asked questions

How does the tool know the file type?

Most file formats start with a fixed signature, called magic bytes: PDF files begin with %PDF, PNG with the bytes 89 50 4E 47, ZIP with PK. The decoder compares the first bytes with a table of known signatures and, for ZIP-based formats, looks at the file names inside to tell DOCX, XLSX, PPTX, EPUB, JAR and APK apart.

What if the data URI says a different MIME type?

The declared type in data:<mime>;base64 is only a label and is sometimes wrong (for example application/octet-stream). The tool trusts the bytes, shows a warning when they disagree and uses the detected type for the extension. If no signature matches, the declared type is used.

Why do I get 'invalid character' or 'truncated' errors?

Base64 only contains A–Z, a–z, 0–9, + and / (or - and _ in the URL-safe variant) plus = padding. Other characters usually mean the text was URL-encoded, HTML-escaped or cut off. A length that leaves one leftover character after grouping by four is impossible, which means part of the string is missing.

How big is the decoded file compared with the Base64 text?

Base64 encodes every 3 bytes as 4 characters, so the file is about 75% of the Base64 length (characters × 3 ÷ 4, minus one byte per = padding sign). For example, 1,000,000 Base64 characters decode to roughly 750 KB.

Can I decode very large Base64 strings?

Yes, up to tens of megabytes, limited only by your browser's memory. Pasting extremely long text can make the text box slow; opening the Base64 from a .txt file is faster.

Is it safe to decode Base64 from an unknown source?

Decoding and previewing are safe: HTML and SVG are shown as text or a static image, and nothing is executed. The decoded file itself can still be harmful, so do not run executables or open macro-enabled documents you do not trust.

Is my data uploaded?

No. Decoding uses the browser's built-in atob function and runs entirely on your device. The Base64 text and the decoded file never leave your computer.

Are all the tools on FreeToolCabin tested for quality and accuracy?

Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.

Related tools

File to Base64Convert any file to a Base64 string or data URI with MIME detection, line wrap and download.Base64 to ImagePaste a Base64 string or data URI to preview, identify and download the image.Base64 to PDFDecode a Base64 string to a PDF with preview and download, or encode a PDF to Base64.Base64 Encoder DecoderEncode or decode Base64 text and files, and make data URIs.Password GeneratorCreate strong passwords and passphrases.Hash GeneratorGenerate MD5, SHA-1, SHA-256 and SHA-512 hashes of text or files.MD5 Hash GeneratorGenerate MD5 hashes of text, lines or files and verify checksums.SHA-256 Hash GeneratorSHA-256 and HMAC-SHA256 hashes of text, lines or files, in hex or Base64.URL Encoder DecoderPercent-encode or decode URLs, query strings and form data.HTML Entity Encoder / DecoderEscape and unescape HTML entities, named or numeric.Bcrypt Hash Generator & CheckerCreate bcrypt password hashes and check a password against a hash.Binary TranslatorConvert text to binary, hex, octal and back.HMAC GeneratorGenerate and verify HMAC signatures with SHA-256, SHA-512, SHA-1 or MD5.CRC32 Checksum CalculatorCalculate CRC-32, CRC-32C, CRC-16 and Adler-32 checksums of text or large files.JWT DecoderDecode JSON Web Tokens, read the claims and expiry, and verify HS256 signatures.JWT GeneratorCreate and sign HS256, HS384 or HS512 JSON Web Tokens in your browser and verify them.Password Strength CheckerSee how strong a password really is, how long it takes to crack and how to improve it.Caesar CipherEncode and decode Caesar shift ciphers and crack unknown shifts with a ranked brute force.Vigenère CipherEncrypt and decrypt Vigenère and Autokey ciphers, and crack unknown keys with frequency analysis.Atbash CipherEncode and decode Atbash ciphers (A↔Z, B↔Y) in Latin or Hebrew, with a live letter mapping table.ASCII TableFull ASCII code chart 0–255 in decimal, hex, octal, binary and HTML, with search and copy.Unicode Character LookupFind Unicode characters by name or code point and copy them with UTF-8, HTML and code escapes.Punycode ConverterConvert international domain names, emails and URLs between Unicode and xn-- Punycode, in bulk.JSON Escape / UnescapeEscape text for a JSON string, unescape \n and \" back to text, or stringify a whole object.Binary to HexConvert binary to hex instantly with steps and signed mode.Hex to BinaryConvert hex to binary instantly with steps and signed mode.Binary CalculatorAdd, subtract, multiply, divide, AND, OR, XOR and shift binary numbers with decimal values.Hex CalculatorHexadecimal + − × ÷ and AND, OR, XOR, NOT, shifts with decimal and binary equivalents.Base32 Encoder / DecoderEncode and decode Base32 (RFC 4648), Base32hex, Crockford and z-base-32 from text, hex or files.Base58 Encoder / DecoderEncode and decode Base58 and Base58Check (Bitcoin alphabet) from text or hex, with checksum verification.Unicode Escape / UnescapeConvert text to \uXXXX, \u{...}, \x, &#...; or CSS escapes and decode them back.File Hash CheckerGet MD5, SHA-1, SHA-256 and SHA-512 checksums of files and verify them against a hash.TOTP GeneratorGenerate 2FA one-time codes from a secret key, create otpauth QR codes and verify codes.RSA Key GeneratorGenerate 2048, 3072 or 4096-bit RSA key pairs as PEM, PKCS#1, JWK or OpenSSH, locally.SSL Certificate DecoderDecode PEM SSL/X.509 certificates: subject, issuer, expiry, SANs, key and fingerprints.Text Encryption ToolEncrypt and decrypt text with a password using AES-256-GCM, entirely in your browser.Argon2 Hash GeneratorHash passwords with Argon2id, Argon2i or Argon2d and verify them against an encoded hash.Bitwise CalculatorCalculate AND, OR, XOR, NOT and bit shifts at 8–64 bits with a bit grid and all bases.SSL Certificate ConverterConvert SSL certificates and keys between PEM, DER, PFX/P12 and P7B in your browser.Checksum CalculatorCompute 8-bit sum, two's complement LRC, XOR/BCC, NMEA, Fletcher and Internet checksums of bytes.PBKDF2 Hash GeneratorDerive PBKDF2 keys from a password, salt and iteration count with SHA-1, SHA-256 or SHA-512.Protobuf DecoderDecode raw Protocol Buffers hex or Base64 without a schema, or add a .proto for field names.XML Escape / UnescapeEscape & < > " ' for XML text and attributes, unescape entities back, or wrap text in CDATA.Binary Search Tree VisualizerInsert, delete and find in BST, AVL and red-black trees with animated rotations and traversals.CSR GeneratorCreate a certificate signing request (CSR) and private key with SANs, RSA or ECDSA, in your browser.MongoDB ObjectId to TimestampDecode a MongoDB ObjectId to its creation date, or build ObjectIds from dates for range queries.PGP Encrypt / DecryptEncrypt, decrypt, sign and verify PGP messages with your armored keys, entirely offline.PGP Key GeneratorGenerate an OpenPGP key pair (Curve25519, NIST ECC or RSA) with passphrase and expiry, offline.Quoted-Printable Encoder / DecoderEncode or decode quoted-printable email text (MIME) with UTF-8 and 76-character soft line breaks.Self-Signed Certificate GeneratorCreate a self-signed SSL certificate and key for localhost or dev servers, as PEM or PFX.SHA-1 Hash GeneratorSHA-1 and HMAC-SHA1 of text or files in hex or Base64, plus Git blob hashes and verify.SHA-512 Hash GeneratorSHA-512 and SHA-384 hashes of text or files in hex or Base64, HMAC and hash verification.SRI Hash GeneratorCreate Subresource Integrity hashes (sha256/384/512) and ready <script> or <link> tags.SSH Key GeneratorGenerate Ed25519 or RSA SSH key pairs in your browser: OpenSSH public key plus private key.String Escape / UnescapeEscape or unescape strings for JavaScript, Java, C#, Python, C, SQL, regex, CSV and shell.UTF-8 Encoder / DecoderConvert text to UTF-8 bytes in hex, decimal, binary, \x or % and decode bytes back to text.UUID Decoder & ValidatorDecode any UUID: version, variant, v1/v6/v7 timestamp and MAC node, plus bulk validation.File Encryption ToolEncrypt and decrypt any file with a password using AES-256-GCM, entirely in your browser.Passphrase GeneratorMake strong, memorable diceware passphrases from a 7,776-word list, with entropy in bits.CSR DecoderDecode a PEM certificate signing request: subject, SANs, key size, signature and CA readiness checks.Enigma Machine SimulatorEncrypt and decrypt with a virtual Enigma I, M3 or M4: rotors, rings, plugboard and lampboard.Hex Opacity CalculatorConvert opacity percent to a 2-digit HEX alpha code and full #RRGGBBAA color, with a 0-100% table.Playfair CipherEncrypt and decrypt Playfair ciphers from a keyword, with the 5x5 key square and every digraph step.Pwned Password CheckerCheck if a password appeared in data breaches; only 5 characters of its SHA-1 hash are sent.RSA Encryption ToolEncrypt text with an RSA public key and decrypt it with the private key using RSA-OAEP in your browser.SAML DecoderDecode SAMLRequest and SAMLResponse messages to readable XML, attributes and validity times.
See all 65 Encoders, Hashes & Crypto →