Base64 Encoder/Decoder
Quickly encode and decode Base64 strings with text and file conversion support
Base64 Encoding Documentation
What is Base64?
Base64 is an encoding scheme based on 64 printable characters to represent binary data. These characters include uppercase and lowercase letters, numbers, and some special symbols. Base64 is widely used in scenarios where binary data needs to be transmitted through text channels, such as email attachments, URL parameters, etc.
Base64 Encoding Algorithm
The Base64 encoding process can be divided into the following steps:
- Split input data into groups of 3 bytes each
- Reorganize these 3 bytes (24 bits total) into 4 blocks of 6 bits
- Map each 6-bit value (range 0-63) as an index to the Base64 character table
- If the last group has less than 3 bytes, pad with 0 bits and add the corresponding number of equals signs (=) at the end as padding symbols
Base64 Character Set: A-Z, a-z, 0-9, +, /
Padding Character: =
Example Conversion:
ASCII code of text "Man": 77 97 110
Binary representation: 01001101 01100001 01101110
Reorganized into 6-bit: 010011 010110 000101 101110
Decimal values: 19 22 5 46
Base64 result: T W F u
Common Uses
- Email attachment encoding (MIME standard)
- Safe data transmission in URLs (using Base64url variant, where '+' and '/' are replaced with '-' and '_')
- Embedding binary images into HTML or CSS (data URI scheme)
- Storing simple data as a single string (such as JWT token components)
- Including binary data in XML and JSON (avoiding special character escape issues)
Notes
- Base64 encoded data is typically about 33% larger than the original data (because 3 bytes become 4 characters)
- Base64 is not an encryption algorithm, just an encoding method, providing no security
- Base64 encoding of large files may consume more memory and processing time
- URL-safe Base64 variants use different character sets to avoid URL encoding issues
- Standard Base64 may contain line breaks to limit line length, which requires additional handling in some applications
Advanced Features
Hex Format Support
Our tool supports hex format input and output, which is very useful for developers working with binary data in program code.
- Input: Accepts 0x11,0x22,0x33 or simple 112233 format
- Output: Convert decoded Base64 back to hex format for embedding in code
Charset Support
Different charsets encode text into bytes differently. Our tool supports multiple charsets to handle various text encodings:
- UTF-8: UTF-8: Universal encoding supporting all Unicode characters (default)
- ASCII: ASCII: 7-bit encoding supporting basic English characters (0-127)
- Latin-1 (ISO-8859-1): Latin-1 (ISO-8859-1): 8-bit encoding supporting Western European characters
- UTF-16: UTF-16: 16-bit encoding commonly used in Windows and Java
Base64 vs Other Encodings
| Encoding Method | Features | Main Uses |
|---|---|---|
| Base64 | Uses 64 ASCII characters to represent binary data | Email attachments, binary data transmission in text |
| URL Encoding | Converts special characters to %XX format | URL parameter passing, form submission |
| Hex Encoding | Each byte represented by two hexadecimal characters | Hash value representation, binary data visualization |
Frequently Asked Questions
Is Base64 encryption?
No, Base64 is an encoding scheme, not encryption. Its purpose is to safely transmit binary data through text protocols (such as email, web pages). Anyone can decode it.
Why does Base64 increase file size?
Base64 uses 4 ASCII characters to represent every 3 bytes of binary data, which causes data size to increase by approximately 33% (i.e., 4/3).
What is "URL-safe" Base64?
Standard Base64 uses '+' and '/' characters. URL-safe Base64 replaces these with '-' and '_' to ensure the string is also safe in URLs and filenames, preventing parsing errors.
Is my data secure?
Yes. This tool runs entirely in your browser using JavaScript. Your files and text are never sent to our servers, ensuring 100% privacy and security.