Base64
Base64 maps arbitrary binary data onto 64 printable ASCII characters (A-Z, a-z, 0-9, +, /) so that binary data can travel over text-only channels.
Purpose
It solved the problem of early mail systems that could carry only 7-bit ASCII text and could not transport binary attachments directly, while keeping control characters from being mangled by gateways.
Mechanism
The input byte stream is processed in 3-byte (24-bit) groups split into four 6-bit units, each mapped to one character of the Base64 alphabet. A final short group is padded with = to 4 characters. The encoded length is about 4/3 of the input, and the output length is always a multiple of 4.
Use cases
- Embedding binary data in JSON, XML, and URLs (e.g., small images in Data URLs)
- MIME attachment transport in email
- Encoding username:password in HTTP Basic authentication
- Encoding the header and payload segments of a JWT
Examples
- Input
HelloOutputSGVsbG8=5 bytes to 8 characters with one trailing = pad
Common errors
- Using standard Base64 directly in URLs, where + and / get percent-encoded and decoding fails
- Use Base64URL instead (- and _ replace + and /, and = padding is dropped)
Related terms
Base32
Base32 maps binary data onto a 32-character alphabet (A-Z and 2-7); the output uses only uppercase letters and digits, which makes it easy to read aloud and type by hand. GLOSSARY
Base16
Base16 is hexadecimal encoding: every 4 bits map to one hexadecimal character (0-9, A-F), making it the simplest member of the Base family defined by RFC 4648. GLOSSARY
Hexadecimal
Hexadecimal (hex) is the base-16 numeral system, using 0-9 and A-F for 0-15; it is one of the most common radix notations in computing. GLOSSARY
MIME Encoding
MIME (Multipurpose Internet Mail Extensions) encoding defines the mechanisms for transporting non-ASCII text and binary attachments in email, including the Base64 and Quoted-Printable content transfer encodings. GLOSSARY
Related tools
Base64 Encoder
Encode text or binary data to Base64 online. Free, private, and 100% client-side. TOOL
Base64 Decoder
Decode Base64 data back to readable text online. Free, private, and 100% client-side. TOOL
Base64 to File
Decode Base64 data URL to downloadable file. Free, private, 100% client-side. TOOL
Base64 Image Preview
Preview Base64 image and show metadata. Free, private, 100% client-side. TOOL