Encode Any File to Base64 — and Decode It Back
Base64 is the bridge between binary files and text-only channels. Email attachments, JSON APIs, XML payloads, configuration files, data URIs in web pages — all of them move binary data as Base64 text. This tool works in both directions: load any file and receive its Base64 representation (plain or as a data URI), or paste a Base64 string and download the decoded file. Both operations run completely inside your browser through the FileReader API, so the files involved never touch a server.
Encoding a File
- Drop any file onto the upload zone — documents, images, fonts, archives, certificates; the format is irrelevant because Base64 works on raw bytes.
- Choose the output style: plain Base64 (just the encoded data) or a data URI (prefixed with the file's MIME type, ready for embedding in HTML or CSS).
- Copy the result with one click, or download it as a text file when the string is too large for comfortable clipboard use.
- The size readout shows the original size and the encoded size — Base64 output is always about 33 percent larger, which is normal.
Decoding Base64 Back to a File
- Switch to the Decode tab and paste your Base64 string. Data URI prefixes are detected and handled automatically.
- Enter a filename for the output (the tool suggests an extension when the data URI declares a type).
- Click Decode & download — the original binary file is reconstructed exactly, byte for byte.
Where This Tool Earns Its Keep
- API development: many APIs accept or return files as Base64 fields; encode test files for requests and decode responses to inspect what came back.
- Email and ticket systems: extract an attachment from a raw MIME source by decoding its Base64 block.
- Configuration secrets: certificates and keys are routinely stored Base64-encoded in environment variables and config files.
- Single-file documents: embed fonts or images into self-contained HTML deliverables.
- Quick transport: move a small binary through a channel that only accepts text — a chat, a code comment, a database field.
Accuracy, Limits and Privacy
Base64 is a lossless, perfectly reversible encoding — encode a file and decode the result, and you get an identical file, which you can prove with the File Hash Generator on this site. The decoder tolerates whitespace and line breaks inside pasted strings (common when copying from emails or terminal output) and reports clearly when a string contains invalid characters rather than producing a silently corrupted file. Practical size limits are generous: browsers handle strings of tens of megabytes comfortably, though manipulating very large Base64 text in a textarea becomes slow — for big files, the download-as-text option is the smoother path. As always on this site, processing is local by construction: encode a contract, a private key or an unreleased build, and the only copy that exists is the one on your screen.
A Worked Example
Suppose an API expects a PDF as a Base64 field in a JSON request. Drop the PDF here, copy the plain Base64 output, and paste it as the field value — done. When the API later returns a document the same way, copy the field's value into the decode tab, name the output file with a .pdf extension, and download the reconstructed document. Both directions take seconds, and neither requires writing a line of code, which makes this tool a favorite during API exploration and debugging sessions.
Frequently Asked Questions
Is Base64 encoding a form of encryption?
No — this is important. Base64 is just a representation, instantly reversible by anyone. It hides nothing. To protect a file’s contents, you need actual encryption; Base64 only changes the format.
Why is the encoded output larger than my file?
Base64 encodes every 3 bytes as 4 ASCII characters, adding roughly 33 percent. That overhead is inherent to the format and identical in every correct implementation.
Will the decoded file be identical to the original?
Yes, byte for byte. Base64 is lossless in both directions. You can verify it: hash the original and the decoded copy with the File Hash Generator — the digests will match.
My pasted Base64 has line breaks — is that a problem?
No. The decoder strips whitespace and newlines automatically, since copied Base64 from emails and terminals is usually wrapped. Genuinely invalid characters produce a clear error instead of a corrupt file.