Understand this tool
Base64 is an encoding, not protection
- What the concept means
- Base64 is a binary-to-text encoding that represents arbitrary bytes with a restricted alphabet of printable characters.
- Why it exists
- It lets binary data travel through systems designed around text, including MIME email bodies and textual protocol fields.
- When to use it
- Use it when a format explicitly requires Base64; do not use it to hide secrets.
- What the result means—and does not mean
- Decoding only reverses a representation. Base64 provides no encryption, integrity, authentication, compression, or proof that decoded bytes are safe.
History and standardization
The earliest standardized use of the modern MIME Base64 alphabet can be traced to Privacy-Enhanced Mail work published in 1987. MIME later adopted the encoding for email content, and RFC 4648 documented the common Base64 and Base64URL alphabets. It is more accurate to describe this standards lineage than to name one inventor.
Different systems had earlier radix-64 encodings, so “Base64” is a family name as well as the common RFC 4648 encoding. Protocol rules decide whether padding or line wrapping is required.
How 24 input bits become four characters
The encoder takes three bytes, or 24 bits, splits them into four six-bit groups, and maps each number from 0 to 63 to one alphabet character. Four output characters therefore represent three input bytes, producing roughly a 4:3 size expansion before line breaks or surrounding syntax.
If the final group contains one or two bytes, zero bits complete the last six-bit group and “=” characters commonly mark the missing input bytes. Padding is metadata, not part of the original data. Base64URL replaces “+” and “/” with “-” and “_” so the text is safer in URL and filename contexts.
Key concepts
Key concepts
- Base64
- The common 64-symbol binary-to-text encoding family.
- Binary-to-text encoding
- A reversible representation of bytes using text characters.
- Base64 alphabet
- The 64 symbols assigned to six-bit values.
- Six-bit group
- A number from 0 to 63 mapped to one Base64 character.
- Padding
- Trailing “=” markers used to signal an incomplete final three-byte block.
- Base64URL
- The URL-safe alphabet variant defined by RFC 4648.
- MIME
- Internet email standards that standardized widespread Base64 use.
Method or process
How the process works
How 24 input bits become four characters
The encoder takes three bytes, or 24 bits, splits them into four six-bit groups, and maps each number from 0 to 63 to one alphabet character. Four output characters therefore represent three input bytes, producing roughly a 4:3 size expansion before line breaks or surrounding syntax.
If the final group contains one or two bytes, zero bits complete the last six-bit group and “=” characters commonly mark the missing input bytes. Padding is metadata, not part of the original data. Base64URL replaces “+” and “/” with “-” and “_” so the text is safer in URL and filename contexts.
Compare the concepts
Related Base64 variants
| Variant | Alphabet detail | Typical context |
|---|---|---|
| Standard Base64 | + and / | General RFC 4648 data |
| MIME Base64 | Standard alphabet with MIME line rules | Email bodies |
| Base64URL | - and _ | URLs, filenames, JWT segments |
Common mistakes
Common mistakes
- Calling Base64 encryption.
- Assuming every decoder accepts omitted padding.
- Encoding visible text without agreeing on its byte encoding.
Edge cases and limits
Edge cases and limits
- Whitespace acceptance depends on the surrounding protocol.
- Malformed padding may be rejected.
- Decoded bytes may not be valid UTF-8 text.