What Base64 encoding does to a file
Base64 encoding takes the raw byte sequence of a file — whatever those bytes represent, whether text, image, executable, or archive — and re-expresses them using only 64 printable ASCII characters (A-Z, a-z, 0-9, +, /). The output is text-safe: it survives copy-paste, email transport, JSON serialisation, XML CDATA, URL query strings (with the url-safe variant), and any protocol that requires 7-bit ASCII. The tradeoff is a fixed ~33% size increase — every 3 bytes of source become 4 bytes of Base64 output, plus optional padding characters (=).
This tool operates on the file's raw bytes exactly as the operating system stores them. It does not decompress, decrypt, transcode, or interpret the contents in any way. A ZIP file encoded to Base64 and then decoded produces an identical ZIP file, verified by SHA-256 hash. This is why Base64 is safe for arbitrary binary data — the encoding preserves every bit.
How to encode a file — three methods
Method 1 is the tool above: drag-and-drop or use the file picker. The browser reads bytes locally, runs Base64 encoding, and returns the string.
Method 2 is the command line. On macOS and Linux, base64 is preinstalled:
Command line (macOS/Linux)
# Encode a file, output single line
base64 -i input.pdf -o output.b64
# Or pipe to clipboard on macOS:
base64 -i input.pdf | pbcopy
# On Linux with xclip:
base64 input.pdf | xclip -selection clipboardPython (any file, cross-platform)
import base64
with open('input.pdf', 'rb') as f:
encoded = base64.b64encode(f.read()).decode('ascii')
print(encoded)Node.js (any file)
import { readFileSync } from 'fs';
const encoded = readFileSync('input.pdf').toString('base64');
console.log(encoded);Typical use cases
JSON API payloads. Payment APIs (Stripe file uploads, PayPal disputes), e-signature APIs (DocuSign, HelloSign), OCR services, and many cloud vision APIs expect the file inline as a Base64 field. The endpoint decodes on the server side — you never touch multipart/form-data.
Email attachments. RFC 2045 (MIME) mandates that binary attachments in email be encoded using Base64. Most SMTP libraries do this transparently, but when constructing raw MIME messages (e.g. via the Gmail API's raw send endpoint), you have to encode the file yourself.
Database text columns. Some databases (older MySQL, SQLite) do not have a first-class BLOB type or make it awkward to work with. Storing a Base64 string in a TEXT column trades ~33% size for query simplicity and portability.
Git version control of binary files. Committing a binary file to Git works but produces unreadable diffs. Committing the Base64 version makes diffs textual and searchable — useful for small binary configs, embedded firmware, or PDF test fixtures.
Size math and when to use streaming
The formula is exact: Base64 output size = ceil(input_bytes / 3) × 4. A 1 MB file produces ~1.33 MB of Base64. A 20 MB video produces ~26.6 MB of text — still workable but noticeably slower to paste. Above 50 MB, browser clipboard limits and JSON parser limits become the bottleneck.
For large files, use streaming Base64 encoding on a backend rather than this tool. Python's base64.encodebytes() processes input in chunks; Node.js streams support base64 encoding natively. For files above 100 MB, do not use Base64 at all — use multipart/form-data uploads or presigned S3 URLs. Base64 is for embedding, not for transport of large blobs.
Security notes
Base64 is not encryption. It is trivially reversible — anyone with the output can decode back to the original file. Never treat Base64 as a way to hide sensitive data. If you need confidentiality, encrypt the file first (AES-256-GCM), then Base64-encode the ciphertext.
Client-side only. This tool never sends your file bytes anywhere. Verify with your browser's DevTools Network tab — no requests are made when you drop a file. That said, once you paste the Base64 output into another system, the bytes of your file are effectively in that system's logs, database, and backups. Handle accordingly.
Filename is not preserved. Base64 encodes bytes, not metadata. If the receiving system needs the original filename, MIME type, or timestamps, send them as separate fields alongside the Base64 payload.
Related Base64 & Encoding Tools
- Base64 Encoder (Parent Tool) — the underlying encoder used by every variant on this page
- Base64 Encode Online — general-purpose text encoder with copy-to-clipboard
- Text to Base64 — convert plain text or UTF-8 to Base64
- Base64 Encode in JavaScript — btoa(), TextEncoder, and Buffer.from() patterns
- Base64 Encode in Python — base64.b64encode() reference and examples
- Base64 Decoder — reverse the encoding — Base64 back to text or file
- Base64 to Image Converter — decode a data URI back into a viewable image file