What is Base64, and when should you use it?
Base64 turns bytes into a predictable set of printable characters so binary or Unicode data can travel through text-oriented systems. It is a transport encoding—not compression, encryption, or a way to protect data.
What is Base64?
Base64 is a binary-to-text encoding defined by RFC 4648. It maps each
6-bit value to one of 64 ASCII characters: uppercase letters, lowercase
letters, digits, and two symbols. An optional = character
completes the final four-character group when the input byte count is not
divisible by three.
Text must become bytes before it can be encoded. This tool uses UTF-8, so Unicode text and emoji are first represented as UTF-8 bytes and then converted to Base64. Decoding reverses those steps.
How Base64 encoding works
Three 8-bit bytes become four 6-bit alphabet indexes.
- UTF-8 input
Man- Three bytes
4D 61 6E- Four characters
TWFu
RFC 4648 groups 24 input bits—three bytes—and divides them into four 6-bit values. Because every three input bytes normally produce four text characters, Base64 output is roughly one-third larger than the original data before line wrapping or surrounding format overhead.
Base64 vs base64url
The bit conversion is the same; two alphabet characters differ.
| Variant | Values 62 and 63 | Padding | Choose it for |
|---|---|---|---|
| Base64 | + and / | = completes the final group unless another specification says otherwise | General text protocols and formats that explicitly expect standard Base64 |
| base64url | - and _ | May omit = when the data length is known implicitly | URLs, filenames, and formats that explicitly require the URL-safe alphabet |
Practical rules for choosing and decoding
Use the required alphabet
Do not swap Base64 and base64url by assumption. The surrounding API, file format, or protocol should name the expected variant.
Agree on UTF-8
Base64 preserves bytes, not character meaning. Both sides must use the same character encoding when those bytes represent text.
Reject malformed data
Unexpected characters or impossible padding can signal corruption. Decode according to the rules of the format that carries the value.