I Love Text
Base64 Encoder/Decoder: Complete Guide to Text Encoding
Encode text to Base64 and decode Base64 back to readable text instantly. Perfect for developers, API integration, and data encoding. Free online Base64 tool.
By Rojan Acharya · Published April 5, 2026 · Last updated April 5, 2026
Base64 Encoder/Decoder: Complete Guide to Text & Data Encoding
Base64 is everywhere in modern web development—from API authentication to email attachments to data URIs. Our free Base64 Encoder/Decoder instantly converts text to Base64 and decodes Base64 back to readable text, supporting full UTF-8 character sets.
This guide explains when and why you need Base64, shows practical use cases, and walks through encoding/decoding processes.
What Is Base64?
Base64 is a binary-to-text encoding scheme that converts binary data into a text format using 64 printable ASCII characters:
- A-Z (26 characters)
- a-z (26 characters)
- 0-9 (10 characters)
- +/ (2 special characters)
Why "Base64"? Uses base-64 numbering system (64 possible characters).
How It Works
Every 3 bytes of binary data converts to 4 Base64 characters:
- 3 bytes = 24 bits
- 24 bits ÷ 6 bits per Base64 character = 4 characters
Example: "Hello" encodes as "SGVsbG8="
The "=" padding ensures output length is multiple of 4.
Why Base64 Matters
API Authentication
Many APIs require Base64-encoded credentials:
Header: Authorization: Basic base64(username:password)
Example: Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
Without Base64 encoding, credentials would be plaintext in headers (security risk).
Email Attachments
Email systems originally supported text-only. Base64 encodes binary attachments as text, allowing email transmission of PDFs, images, etc.
Data URIs
Embed images directly in HTML/CSS:
<img src="data:image/png;base64,iVBORw0KGgoAAAANS...">
Eliminates separate HTTP requests for small images.
API Payloads
Some APIs require Base64-encoded content in JSON:
{
"document": "base64encodedpdfcontent",
"filename": "document.pdf"
}
Configuration Files
Some configuration systems use Base64 for sensitive values (not secure, but obfuscates from casual viewing).
How to Use the Base64 Encoder/Decoder
Encoding (Text → Base64)
Step 1: Paste text to encode Step 2: Tool automatically encodes to Base64 Step 3: Copy Base64 output
Decoding (Base64 → Text)
Step 1: Paste Base64 string Step 2: Tool automatically decodes to text Step 3: Copy readable output
Practical Examples
Example 1: API Authentication
Scenario: Authenticating to Basic Auth API
Original credentials:
username: apiuser
password: secretkey123
Combined: apiuser:secretkey123
Base64 encoded: YXBpdXNlcjpzZWNyZXRrZXkxMjM=
API request:
GET /api/data HTTP/1.1
Host: api.example.com
Authorization: Basic YXBpdXNlcjpzZWNyZXRrZXkxMjM=
Example 2: Embedding Images in HTML
Scenario: Embed small icon directly in HTML
Original file: logo.png (2.5 KB)
Convert to Base64:
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==" alt="Logo">
Benefits:
- No additional HTTP request
- Reduces initial page load requests
- Good for icons/small images
- Not recommended for large images
Example 3: Email Attachment Encoding
Scenario: Sending PDF via email through API
Original PDF: invoice.pdf (binary data)
Steps:
- Read PDF as binary
- Encode to Base64
- Send in JSON API request:
{
"to": "customer@example.com",
"subject": "Your Invoice",
"attachments": [
{
"filename": "invoice.pdf",
"content": "JVBERi0xLjQK...",
"encoding": "base64"
}
]
}
Example 4: API Request Payload
Scenario: Sending document upload via API
Request:
{
"documentType": "passport",
"fileContent": "base64encodedpdfhere",
"mimeType": "application/pdf"
}
Process:
- Read file as binary
- Encode to Base64
- Include in JSON payload
- Send to API
Tips & Best Practices
Tip 1: Base64 ≠ Encryption
Base64 encodes data but doesn't encrypt it. Anyone can decode Base64:
- ✓ Use for: Obfuscation, data format conversion, API transmission
- ✗ Don't use for: Sensitive data protection (use real encryption instead)
Tip 2: Always Use HTTPS with Base64-Encoded Credentials
Even though Base64 isn't encryption, using Base64 credentials over HTTPS is acceptable:
- HTTPS encrypts the entire request
- Base64 just formats the credentials
- Together: Safe transmission
Tip 3: Payload Size Increases ~33%
Base64 encoding increases data size:
- Original: 100 KB
- Base64 encoded: ~133 KB (33% larger)
For large files, use alternative compression first.
Tip 4: Character Encoding Matters
Use UTF-8 encoding for text:
- Supports international characters
- Standard for web
- Our tool uses UTF-8 by default
Tip 5: Padding Characters Matter
Base64 padding (=) is required:
- Ensures length is multiple of 4
- Remove padding only if system explicitly allows
- Most systems require correct padding
Tip 6: Use For Data URIs Strategically
Good for:
- Small icons (<2 KB)
- Favicons
- Simple graphics
Not recommended for:
- Large images (increases HTML size)
- Images loaded many times (can't be cached separately)
- High-traffic pages (wastes bandwidth)
Frequently Asked Questions
Is Base64 secure?
No. Base64 is not encryption. Anyone can easily decode Base64:
- Use for: Format conversion, non-sensitive data
- Don't use for: Protecting sensitive data
For security, use proper encryption (AES, etc.).
Can I decode any Base64 string?
Almost always, yes. If:
- Valid Base64 format (proper characters)
- Correct padding
- Proper UTF-8 encoded originally
You can decode it.
What characters can appear in Base64?
Valid Base64 characters:
- A-Z (uppercase letters)
- a-z (lowercase letters)
- 0-9 (digits)
-
- and / (operators)
- = (padding)
Any other characters indicate invalid Base64.
What if my Base64 string has spaces or line breaks?
Those are often added for readability in long Base64 strings:
- Remove spaces and line breaks
- Then decode
- Many tools handle this automatically
Can I encode/decode files with this tool?
Our tool handles text. For files:
- Most programming languages have Base64 libraries
- Many online tools support file upload
- Use our tool for text content within files
Does Base64 work with Unicode/special characters?
Yes. Our tool supports full UTF-8:
- Works with emoji, international characters, symbols
- Encodes correctly, decodes back to exact original
- UTF-8 encoding standard ensures compatibility
What's the maximum text length I can encode?
No practical limit. Can handle:
- Very large documents
- Entire files as text
- Gigabytes of data (limited by browser memory)
Why is Base64 in headers sometimes?
HTTP headers need to be text. Base64 converts binary credentials to text format suitable for headers.
Can I use URL-safe Base64?
Yes. Standard Base64 uses +/ characters. URL-safe Base64 uses -_ instead (safe for URLs):
- Standard:
/+characters - URL-safe:
-_characters
Specify which variant your API requires.
Is there a better alternative to Base64?
For different use cases:
- Encryption: Use AES, RSA (for actual security)
- Compression: Use gzip, brotli (for size reduction)
- Canonical format: Use JSON, XML (for readability)
Base64 is best for binary-to-text conversion.
Quick Reference
| Use Case | Format | Example |
|---|---|---|
| API Auth | Authorization: Basic base64(user:pass) | Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ= |
| Data URI | data:mime/type;base64,content | data:image/png;base64,iVBORw0... |
| JSON Payload | "fieldname": "base64content" | "document": "JVBERi0xLjQK..." |
| HTTP Header | Custom-Header: base64value | X-Token: eyJhbGciOiJIUzI1NiJ... |
Related Tools
I Love Text Tools:
- URL Encoder/Decoder: Encode URLs safely
- HTML Entity Encoder: Encode HTML content
- Hex Converter: Convert to hexadecimal
- Binary Converter: Convert to binary
Summary
The Base64 Encoder/Decoder is essential for developers and anyone working with web APIs. By instantly converting between text and Base64:
✓ Authenticate to APIs — Encode credentials for Basic Auth
✓ Embed data in URLs — Create data URIs for images
✓ Transmit binary data — Send files via text-only channels
✓ Format API payloads — Properly encode file uploads
✓ Debug encoding issues — Quickly encode/decode test data
Start using our free Base64 converter today—no signup, 100% private, always free.
Ready to encode/decode? Use I Love Text's Base64 Encoder/Decoder instantly.