What is Base64?
Base64 is an encoding scheme that converts binary data into a text format using 64 printable ASCII characters. It's called "Base64" because it uses 64 different characters to represent data.
The 64 characters are: A-Z, a-z, 0-9, +, and /. The = character is used for padding.
Why Do We Need Base64?
Many systems are designed to handle text, not binary data. Email, for example, was originally designed for text only. Base64 lets us send binary data (like images or files) through text-based systems.
How Base64 Works
Base64 encoding works by taking 3 bytes (24 bits) of binary data and converting them into 4 ASCII characters. Each character represents 6 bits of the original data.
Original: "Hi"
Binary: 01001000 01101001 (2 bytes = 16 bits)
Padded: 01001000 01101001 00000000 (24 bits)
Split: 010010 000110 100100 000000
Base64: S G k =
Result: "SGk="Common Use Cases
1. Data URIs (Embedding Images in HTML/CSS)
Instead of linking to an external image, you can embed it directly:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAAB...">2. API Authentication
HTTP Basic Authentication uses Base64 to encode credentials:
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=3. JSON Web Tokens (JWT)
JWTs use Base64URL encoding for the header and payload sections.
4. Email Attachments
MIME encoding uses Base64 to include binary attachments in emails.
When NOT to Use Base64
- Encryption: Base64 is NOT encryption. Anyone can decode it.
- Large files: Base64 increases size by ~33%.
- Passwords: Never "encode" passwords with Base64 - use proper hashing.
Base64 vs Base64URL
Standard Base64 uses + and / characters, which have special meaning in URLs. Base64URL replaces these with - and _ to make the output URL-safe.
Try It Yourself
Use our Base64 Encoder/Decoder to encode and decode Base64 strings instantly.