π Base64 Encoder
π Base64 Decoder
π§ͺ Example Base64 Operations
Click an example to see Base64 encoding in action
π Understanding Base64 Encoding
Base64 is a binary-to-text encoding scheme that converts binary data into ASCII text format using 64 characters (A-Z, a-z, 0-9, +, /). It's essential for transmitting binary data over text-based protocols that only support ASCII.
How Base64 Works:
- Character Set - Uses 64 characters: A-Z (26), a-z (26), 0-9 (10), + and / (2)
- Encoding Process - Every 3 bytes (24 bits) of input are split into four 6-bit groups, each encoded as one Base64 character
- Padding - Uses '=' character to pad output when input isn't divisible by 3
- Size Increase - Output is approximately 33% larger than input (4 characters for every 3 bytes)
- UTF-8 Support - Our tool handles Unicode text correctly by first encoding to UTF-8
Common Use Cases:
- Email Attachments (MIME) - Standard encoding for email attachments in SMTP protocol
- Data URIs - Embed images directly in HTML/CSS using data:image/png;base64,...
- JSON/XML Storage - Store binary data in text-based formats
- Basic HTTP Authentication - Username:password encoded as Base64 in Authorization header
- JWT Tokens - JSON Web Tokens use Base64URL encoding for header and payload
- API Communication - Transmit files and binary data via REST APIs
- Database Storage - Store binary blobs in text columns
Base64 vs Base64URL:
- Base64 - Uses + and / characters, requires = padding. Used in MIME, email.
- Base64URL - Uses - and _ instead of + and /, no padding. URL-safe, used in JWT tokens.
- When to use - Use Base64 for general encoding. Use Base64URL for URLs and filenames.
Best Practices:
- Don't use Base64 for security - it's encoding, not encryption
- Remove whitespace and line breaks before decoding
- Use Base64URL for URLs to avoid special character issues
- Consider compression before encoding large data
- For images in HTML, use data URIs sparingly (impacts page load)
- Remember the 33% size overhead when planning storage
β οΈ Privacy Note: All encoding and decoding happens locally in your browser. No data is transmitted to servers.
β Frequently Asked Questions
Base64 is a binary-to-text encoding scheme that converts binary data into ASCII text format using 64 characters (A-Z, a-z, 0-9, +, /). It's used to safely transmit binary data over text-based protocols like email, HTTP and JSON. Every 3 bytes of input are encoded into 4 Base64 characters, increasing data size by approximately 33%.
Use Base64 encoding for: embedding images in HTML/CSS (data URIs), email attachments (MIME encoding), storing binary data in JSON/XML, Basic HTTP Authentication, JWT tokens, transmitting files via APIs, encoding binary data for databases that only support text and including binary assets in configuration files.
JWT tokens have three Base64-encoded parts separated by dots: header.payload.signature. To decode: 1) Split the JWT by dots, 2) Take the middle part (payload), 3) Use our Base64 decoder to decode it. The result is a JSON object containing your token's claims and data. Note: Decoding a JWT does not verify its signature.
Base64 encoding increases size by ~33% because it represents 3 bytes (24 bits) of binary data using 4 Base64 characters (24 bits in 6-bit chunks). This overhead is the cost of converting binary data to text-safe format. For example, a 100KB image becomes ~133KB when Base64 encoded.
This tool is designed for text encoding. For image files, you'll need to first read the file as binary data. In modern browsers, you can use FileReader API to read files as data URLs (which are Base64 encoded). Our tool works best for encoding text strings, JSON data and decoding existing Base64 strings.
Absolutely! All Base64 encoding and decoding happens locally in your browser using JavaScript. No data is ever transmitted to our servers or any third party. You can use this tool completely offline. Your data never leaves your device.