← Back to all tools

🔐 Base64 Encoder & Decoder

Convert between plain text and Base64 encoding instantly.

💡 What is Base64?

Base64 encoding converts binary data into ASCII text. Common uses: encoding credentials for HTTP Basic Auth, embedding images in CSS/HTML, or safely transmitting data in URLs and JSON.

📚 Understanding Base64 Encoding

Base64 is an encoding scheme that converts binary data into ASCII text format using 64 printable characters (A-Z, a-z, 0-9, +, /). It's NOT encryption or compression—it's purely encoding for safe data transmission.

⚠️ Important: Base64 is NOT Secure

Base64 encoding can be easily reversed (decoded). Do NOT use it to hide sensitive information like passwords. Use proper encryption (AES, RSA) for security. Base64 is for encoding, not encrypting.

🎯 Common Use Cases

💡 Practical Examples

Example 1: Encode text to Base64
Input: Hello World!
Output: SGVsbG8gV29ybGQh

// Decoding reverses it perfectly:
Input: SGVsbG8gV29ybGQh
Output: Hello World!
Example 2: HTTP Basic Authentication
// Credentials
Username: admin
Password: secret123

// Combine with colon
Text: admin:secret123

// Encode
Base64: YWRtaW46c2VjcmV0MTIz

// Use in header
Authorization: Basic YWRtaW46c2VjcmV0MTIz
Example 3: Data URL for images
// Small icon as data URL
<img src="data:image/png;base64,iVBORw0KGg..." />

// No HTTP request needed - image is embedded in HTML

❓ Frequently Asked Questions

Is Base64 encoding safe for passwords?

NO! Base64 is easily reversible. Anyone can decode it. Use proper password hashing (bcrypt, Argon2) or encryption (AES-256) for sensitive data. Base64 is for encoding, not security.

Why does Base64 increase data size?

Base64 increases size by ~33%. This is because it converts 3 bytes (24 bits) into 4 Base64 characters. Example: 100 bytes becomes ~133 bytes. This trade-off allows binary data to be safely transmitted as text.

What does the = padding mean?

The = character pads the output to a multiple of 4 characters. Example: SGVsbG8= has one padding, SGk= has one. It ensures proper decoding by indicating how many bytes the original data had.

Can I encode files with Base64?

Yes! Images, PDFs, and any binary file can be Base64-encoded. However, large files create very long strings. Base64 is best for small files (icons, small images) or when you need to embed data in text formats (JSON, XML, HTML).

🔧 Using Base64 in Code

JavaScript:
// Encode
const encoded = btoa('Hello World');
console.log(encoded); // SGVsbG8gV29ybGQ=

// Decode
const decoded = atob('SGVsbG8gV29ybGQ=');
console.log(decoded); // Hello World
Python:
import base64

# Encode
encoded = base64.b64encode(b'Hello World')
print(encoded)  # b'SGVsbG8gV29ybGQ='

# Decode
decoded = base64.b64decode(encoded)
print(decoded)  # b'Hello World'