How Base64 Encoding Works
Base64 converts binary data into a text format using 64 printable ASCII characters. It's essential for transmitting data through text-only channels.
The Base64 Alphabet
These 64 characters are safe in virtually all text systems. The = sign is used for padding.
Step-by-Step Encoding Process
"Hi" → 01001000 01101001010010 000110 1001 → Need padding010010 000110 100100 (padded)18, 6, 36 → SGk=Why Does Base64 Increase Size by 33%?
Original: Each byte = 8 bits of data
Base64: Each character represents only 6 bits
Math: 3 bytes (24 bits) → 4 Base64 characters (24 bits)
Result: 4/3 = 1.33... → 33% increase in size
Plus additional overhead from padding (=) and line breaks in some formats.
Base64 Variants
| Variant | Special Chars | Common Use |
|---|---|---|
| Standard Base64 | A-Z, a-z, 0-9, +, / | MIME, PEM, general encoding |
| Base64URL | A-Z, a-z, 0-9, -, _ | URLs, filenames, JWT |
| Base64 (no padding) | Same as standard | Some APIs, compact storage |
Where Base64 Is Used
SMTP only supports 7-bit ASCII. Base64 encodes binary files for transmission.
Embed images directly in HTML/CSS: data:image/png;base64,iVBORw0K...
Safely include binary data in text-based formats without escaping issues.
HTTP Basic Auth encodes username:password as Base64 (not encryption!).
JWT header and payload are Base64URL encoded for URL-safe transmission.
PEM files store certificates and keys in Base64 between BEGIN/END markers.
Security Warning
Base64 is NOT encryption! It's trivially reversible. Anyone can decode Base64 data instantly. Never use it to "hide" sensitive information like passwords, API keys, or personal data.
For security, use proper encryption (AES, RSA) or hashing (bcrypt, Argon2).
External Resources
Try Base64 Encoding Now!
Encode and decode Base64 strings instantly with our free tool.
🔤Open Base64 Encoder/Decoder