The Base64 Character Set Explained
The entire concept of Base64 encoding revolves around translating complex, unpredictable binary data into a highly restricted, universally safe alphabet. This specific alphabet is known as the Base64 Character Set. In this guide, we will examine exactly which characters make up this set, why they were chosen, and how they map mathematically to binary values.
Why 64 Characters?
As discussed in our guide on how the algorithm works, Base64 processes data in 6-bit chunks. A 6-bit binary sequence can represent exactly 64 unique values, ranging from 000000 (which equals 0 in decimal) to 111111 (which equals 63 in decimal). Therefore, the encoding scheme requires an index table containing exactly 64 distinct characters to map to these 64 possible values.
The Standard Base64 Index Table
The standard character set is defined by RFC 4648. The 64 characters are allocated in a highly logical sequence, prioritizing the most basic, universally supported alphanumeric characters.
1. Uppercase Letters (Values 0 - 25)
The first 26 values map directly to the English alphabet in uppercase.
- 0 = A, 1 = B, 2 = C ... 25 = Z
2. Lowercase Letters (Values 26 - 51)
The next 26 values map to the English alphabet in lowercase.
- 26 = a, 27 = b, 28 = c ... 51 = z
3. Numbers (Values 52 - 61)
The following 10 values map to the standard digits.
- 52 = 0, 53 = 1, 54 = 2 ... 61 = 9
4. The Symbols (Values 62 and 63)
Because there are only 62 alphanumeric characters (26 + 26 + 10), the standard requires two additional symbols to complete the 64-character index. The original specification selected the plus sign and the forward slash.
- 62 = + (Plus)
- 63 = / (Forward Slash)
Why Were These Characters Chosen?
The characters in the Base64 alphabet were not chosen at random. They were selected because they are the most robust, cross-platform characters in existence. They are guaranteed to be supported by every legacy mainframe, every modern web browser, every database, and every text editor without being misinterpreted as control characters or triggering formatting errors.
This is why Base64 is so reliable for API transport and JSON payloads—the payload is guaranteed to be pure, safe text.
The Padding Character (The Equals Sign)
You will frequently see Base64 strings ending with one or two equals signs (= or ==). It is important to note that the equals sign is not part of the 64-character index.
The equals sign serves exclusively as a structural padding marker. Because the algorithm must output data in 4-character blocks, the = is used to fill in the missing space if the original input data did not divide evenly into 3-byte blocks. You can read more in our detailed Base64 Padding guide.
Variations of the Character Set
While the standard Base64 character set is perfect for general data transport, the inclusion of the + and / symbols causes severe routing errors if the string is placed directly into a web URL. To solve this, the IETF defined an alternative character set known as Base64URL, which swaps the + for a hyphen (-) and the / for an underscore (_).
To experiment with how different inputs generate different characters from the index, try using our live Online Base64 Encoder.