The encyclopedia · Engineering & Operations · Technical decision · 1987-2006
Base64 packed 6 bits into one printable char and let any binary cross a text-only channel
Base64 mapped every 6 bits to a safe printable character, so images and files could ride inside 7-bit text.
IETF
the move
Email, URLs, XML and JSON are text transports: they can carry bytes, but only a narrow safe subset reliably. Sending a raw image through them mangles it. The clumsy alternative is to ship files as attachments that require special handling, which breaks inside the message body.
Base64 sidesteps this by converting the binary into text. It takes each 3-byte group and splits it into four 6-bit chunks, then prints one character per chunk from a 64-character alphabet, padding with an equals sign when the input does not divide evenly. Every byte in the output is a printable ASCII character.
Because the encoding was fixed once, it became the default for MIME email attachments, HTTP Basic auth, data URIs and JWTs. It did not solve the transport's limits; it designed around them so well that nothing else was needed.
why it works
- The 64-character alphabet was chosen to be safe in every text channel, so no character gets corrupted by a mail system or a parser.
- The 3-to-4 ratio means the output is predictable and reversible with a tiny fixed table, so implementations agree exactly.
- Padding makes the output self-describing, so a decoder knows how many real bytes follow.
- It solved email attachments first, which seeded it into every later format that needed to carry bytes in text.
what transfers
When a channel cannot carry arbitrary data, convert the data into the channel's own safe alphabet; the format that optimizes for the channel's constraints gets used everywhere.
what came after
Base64 was standardized with MIME in the early 1990s and then codified in RFC 4648 in 2006, which also added the URL-safe variant. It is now baked into JSON, XML, HTTP auth, JWTs, and data URIs. Its weakness is the 33 percent size overhead, which newer binary protocols tolerate rather than replace.
references
spotted an error? The archive wants to know.