Text
Base64 Encoder/Decoder
Encode and decode Base64 strings
How to Use the Base64 Encoder/Decoder
The Base64 Encoder/Decoder converts text between readable format and Base64 encoding. Base64 is used for transmitting data across systems that may not handle raw binary or special characters.
- Encode text to Base64.
- Decode Base64 back to text.
- Handle special characters and Unicode.
- Copy encoded/decoded text easily.
- Work with both text and files.
Base64 Encoding Formulas
Understanding Base64 encoding helps with data transmission, API integration, and web development.
Base64 Encoding
Converts readable text to Base64 format.
Example:
Input: "Hello"
Calculation: Convert to ASCII, then to Base64
Result: "SGVsbG8="
Base64 Decoding
Converts Base64 back to readable text.
Example:
Input: "SGVsbG8="
Calculation: Convert from Base64 to ASCII
Result: "Hello"
Encoding Size Increase
Base64 increases size by about 33%.
Example:
Input: 100 bytes
Calculation: 100 × 4 ÷ 3
Result: ~133 bytes when Base64 encoded
Padding
Ensures proper group alignment.
Example:
Input: "Hello" (5 bytes)
Calculation: Pad to multiple of 4
Result: "SGVsbG8=" (8 characters with padding)
Real-World Use Cases
Base64 encoding is widely used in web development, API integration, and data transmission.
Email Attachments
Email systems use Base64 to transmit binary files as text, allowing them to pass through text-only systems.
API Data Transfer
APIs often use Base64 encoding for transmitting binary data (images, files) in JSON payloads.
Data URLs
Embed images directly in HTML/CSS using Base64 encoded data URLs instead of file references.
Credentials & Tokens
Basic authentication uses Base64 encoded username:password for HTTP headers.
Cryptography & Security
Encrypted data is often Base64 encoded for safe transmission and storage.
Tips & Best Practices
Tips
- Base64 is encoding, not encryption; it provides no security.
- Always use HTTPS when transmitting Base64-encoded sensitive data.
- Data URLs with Base64 can bloat HTML/CSS; use sparingly for small images.
- Some systems strip Base64 padding (=) but it can usually be recovered.
- URL-safe Base64 replaces + with - and / with _ for use in URLs.
Common Mistakes to Avoid
- Thinking Base64 provides encryption or security - it's only encoding.
- Using Base64 for large files in HTML, which bloats page size significantly.
- Not handling padding correctly when manually working with Base64.
- Forgetting that Base64 increases data size by approximately 33%.