Base64 is a binary-to-text encoding scheme that represents binary data in an ASCII string format using 64 printable characters (A-Z, a-z, 0-9, +, and /).
The Mathematical Mechanism
Computer systems store data in 8-bit bytes (256 possible values). However, legacy email systems and URL query strings are only guaranteed to transmit printable 7-bit ASCII characters without corruption.Base64 works by:
1. Taking 3 bytes of binary data (24 bits total).
2. Dividing those 24 bits into 4 groups of 6 bits each.
3. Mapping each 6-bit value (0 to 63) to its corresponding character in the Base64 alphabet table.
4. Appending padding characters (=) if the input byte length is not a multiple of 3.
When to Use Base64
- Embedding tiny SVG icons and favicons directly in CSS or HTML to prevent extra network round trips. - Transmitting digital signatures and encrypted keys in JSON payloads. - Basic HTTP authorization headers.Encode or decode Base64 strings safely with our Base64 Encoder & Decoder.