Base64 Encode & Decode - How It Works and When to Use It
Base64 is everywhere - in email attachments, data URLs, API tokens, and image embedding. If you have ever pasted a long string that starts with "eyJ" or "data:image/png;base64,", you have seen Base64 in action. Here is what it is, how it works, and how to encode/decode it for free.
What Is Base64?
Base64 is a binary-to-text encoding scheme that converts binary data into ASCII characters. It uses 64 characters (A-Z, a-z, 0-9, +, /) plus = for padding. The result is about 33% larger than the original binary data.
It is encoding, not encryption - Base64 is reversible and provides zero security. Anyone can decode it.
Common Use Cases
- Data URLs - embed small images directly in HTML/CSS as
data:image/png;base64,... - API authentication - HTTP Basic Auth sends
Base64(username:password) - JWT tokens - the header and payload of a JWT are Base64URL-encoded (use JWT Decoder to inspect them)
- Email attachments - MIME encodes binary files as Base64 for SMTP transport
- JSON in URLs - encode JSON payloads to safely pass them in query parameters
- Embedding fonts - web fonts can be inlined as Base64 in CSS
Base64 vs. Base64URL
Two variants exist with subtle differences:
- Base64 - uses
+and/, padded with=. Standard for email and general encoding. - Base64URL - replaces
+with-and/with_, omits padding. Used in JWTs and URLs where+/=would break.
Use SnapSum Base64 Encode/Decode to handle both variants.
Free Online Base64 Tool
SnapSum Base64 encodes and decodes text and files in your browser. No server upload, no data retention.
- Encode text or files to Base64
- Decode Base64 back to text or download as a file
- Supports Base64URL variant
- Image preview when decoding Base64-encoded images
Step-by-Step: Encode/Decode Base64
- Open Base64 Encode/Decode.
- Paste your text or upload a file.
- Click "Encode" to get Base64 output, or paste Base64 and click "Decode."
- Copy the result or download as a file.
Base64 Is Not Encryption
A common mistake: using Base64 to "hide" sensitive data. Base64 is trivially decodable - it is like writing a secret message in ALL CAPS. For actual security, use encryption (AES, RSA) or password protection (see PDF Protect for document-level security).
Base64 Encoding Quick Reference
- Input size to Output size: approximately 1.33x (33% larger)
- Line length: MIME standard wraps at 76 characters
- Padding: = or == at the end to make the length a multiple of 4
- Alphabet: A-Z (0-25), a-z (26-51), 0-9 (52-61), + (62), / (63)