Base64 Encoding Guide
Encode and decode Base64 strings with our free online tool.
Introduction
Base64 encoding converts binary data to ASCII text format. It's used for:
- Embedding images in HTML/CSS
- Encoding data in URLs
- Email attachments (MIME)
- API data transfer
- Storing binary data in JSON
How to Use
Encoding
- Go to Base64 Encoder/Decoder
- Select Encode mode
- Enter your text or data
- Copy the Base64 output
Decoding
- Select Decode mode
- Paste the Base64 string
- View the decoded output
How Base64 Works
Base64 uses 64 characters:
- A-Z (26 characters)
- a-z (26 characters)
- 0-9 (10 characters)
-
- and / (2 characters)
- = for padding
Every 3 bytes of input become 4 Base64 characters.
Common Use Cases
Embedding Images
Convert small images to Base64 for inline CSS/HTML:
.icon {
background: url('data:image/png;base64,iVBORw0K...');
}
API Authentication
Encode credentials for Basic Auth:
const auth = btoa(`${username}:${password}`);
// Use in header: `Basic ${auth}`
Data URLs
Include small files directly in web pages:
<img src="data:image/png;base64,iVBORw0KGgo..." />
Best Practices
When to Use
- Small images (<10KB)
- Configuration data
- Simple authentication
- Embedding in JSON/XML
When NOT to Use
- Large files (increases size by 33%)
- Performance-critical applications
- Files served separately
- Already compressed data
Security Notes
- Base64 is NOT encryption
- Anyone can decode Base64
- Don't use for passwords alone
- Combine with actual encryption
Related Tools
- Image to Base64 - Convert images
- URL Encoder - URL-safe encoding