How Base64 works
Base64 is a text-safe encoding system that converts any binary data into a string of 64 'safe' characters. It's not encryption—anyone can instantly decode it—but it's essential for transmitting data across systems that only reliably handle plain text (like email, JSON APIs, or HTML attributes).
The process works by grouping your input into chunks, converting each to a number, then mapping that number to one of 64 allowed characters (A–Z, a–z, 0–9, +, /). If the input length isn't a multiple of 3 bytes, padding characters (=) are added at the end.
The formula
Base64 = (input bytes) → (6-bit groups) → (lookup table) → (ASCII characters + padding)
Worked example
Encoding "Hello" to Base64:
Convert each letter to its ASCII value:
- H = 72, e = 101, l = 108, l = 108, o = 111
Convert to binary (8 bits each):
- 01001000 01100101 01101100 01101100 01101111
Group into 6-bit chunks:
- 010010 000110 010101 101100 011011 000110 1111 (last group has only 4 bits, pad with 00)
- 010010 000110 010101 101100 011011 000110 111100
Convert each 6-bit group to decimal:
- 18, 6, 21, 44, 27, 6, 60
Map to Base64 table:
- 18=S, 6=G, 21=V, 44=s, 27=b, 6=G, 60=8
- Result: SGVsbG8=
(The trailing = is padding because "Hello" is 5 bytes, not a multiple of 3.)
Decoding "SGVsbG8=" back to text:
- Remove padding (=) and convert each character back to 6-bit binary
- Regroup into 8-bit bytes
- Convert each byte to ASCII: 72, 101, 108, 108, 111
- Convert to characters: Hello
Common mistakes
- Forgetting that Base64 is not encryption. If you encode a password as Base64 and share it, anyone can decode it. Always encrypt sensitive data first.
- Assuming padding is optional. Padding (=) is required for valid Base64. Decoders expect it.
- Mixing up encode and decode. If you paste Base64 into the Encode field, you'll get garbage. Use the correct action for your input type.
- Losing special characters. When encoding, ensure your input is in UTF-8. Some legacy systems may not display emoji or accented text correctly after decoding if they don't support UTF-8.
- Whitespace sensitivity. Newlines and spaces are encoded as data. If you copy Base64 from a formatted source, remove extra line breaks before decoding.