Base64 encoding is one of those things that appears everywhere — in JWT tokens, in email attachments, in data URIs, in HTTP Basic Auth headers — but is rarely explained clearly. Here is a practical guide to what it is, why it was invented, and when you should and should not use it.

What Is Base64?

Base64 is an encoding scheme that converts binary data (bytes) into a string of 64 printable ASCII characters. Those 64 characters are: A–Z (26), a–z (26), 0–9 (10), + and / (2) — plus = used as padding.

The core problem Base64 solves: not all data transfer systems handle arbitrary bytes safely. Email protocols, HTTP headers, and many older systems were designed to carry text, not binary data. A byte value of 0x00 (null), 0x0A (newline), or 0x1B (escape) can corrupt or terminate a text-based transmission.

Base64 sidesteps this by encoding any binary data as a string of safe, printable characters that nothing misinterprets.