Understanding Base64 Encoding
Base64 is one of those things every developer encounters but few truly understand. Let's fix that.
What is Base64?
Base64 is a binary-to-text encoding scheme that represents binary data using 64 printable ASCII characters. It's designed to carry data stored in binary formats across channels that only reliably support text content.
How Does It Work?
Base64 takes 3 bytes (24 bits) of binary data and converts them into 4 ASCII characters. The character set includes:
- A-Z (26 characters)
- a-z (26 characters)
- 0-9 (10 characters)
-
- and / (2 characters)
- = for padding
When to Use Base64
Good use cases:
- Embedding images in HTML/CSS (data URIs)
- Sending binary data in JSON payloads
- Email attachments (MIME encoding)
- Basic authentication headers
Bad use cases:
- Storing passwords (use proper hashing)
- Encrypting data (Base64 is NOT encryption)
- Compressing data (Base64 increases size by ~33%)
Example
The string "Hello" in Base64 is "SGVsbG8=".
Try it yourself with our Base64 Encoder tool.
Base64 vs Base32 vs Base58
| Encoding | Character Set | Use Case | |----------|---------------|----------| | Base64 | A-Z, a-z, 0-9, +, / | General purpose | | Base32 | A-Z, 2-7 | Case-insensitive systems | | Base58 | No confusing chars | Cryptocurrency addresses |
Conclusion
Base64 is a simple but essential encoding scheme. Understanding it helps you debug APIs, work with file uploads, and handle binary data in web applications.
Try our free developer tools
All tools run in your browser with zero data uploads.