Base64 Encoding Explained — What It Is, How It Works & When to Use It
What is Base64?
Base64 converts binary data into a text-safe alphabet of 64 characters (A–Z, a–z, 0–9, +, /). It exists because many protocols (email, JSON, URLs) were designed for text, not raw bytes.
How It Works
Every 3 bytes (24 bits) become 4 Base64 characters (6 bits each). If input isn't divisible by 3, = padding is added.
"Hi" → bytes [72, 105] → bits 010010 000110 1001xx → "SGk="
Common Uses
- Data URIs: inline images without extra HTTP requests
- API auth: Basic Auth headers (
Authorization: Basic dXNlcjpwYXNz) - JWT tokens: header.payload.signature segments (see our JWT Decoder)
- Email attachments: MIME encoding
⚠️ Base64 Is NOT Encryption
Any Base64 string decodes instantly. Never encode secrets thinking they're protected — it's obfuscation at best. For real security use hashing or proper encryption.
Try It
Use our Base64 Encoder/Decoder — runs entirely in your browser, nothing is uploaded.
FAQ
Why does Base64 make data ~33% bigger?
3 bytes → 4 characters. 8-bit bytes packed into 6-bit characters wastes 2 bits per character.
What's Base64URL?
A URL-safe variant replacing + with - and / with _, padding optional. Used in JWTs and OAuth.