Upload a file
  1. base64hub
  2. Base64 Alphabet Table

Base64 Alphabet Table

Base64 maps every 6-bit value from 0 to 63 to one printable character. Here is the complete table, the URL-safe version, and the facts about which characters show up where.

The 64 characters

Base64 reads the input 3 bytes (24 bits) at a time and splits them into four 6-bit numbers. Each number, from 0 to 63, is an index into this table. The order is fixed by RFC 4648: uppercase letters for 0 to 25, lowercase for 26 to 51, digits for 52 to 61, then + and /. The last column is the ASCII code of the character, which is what actually gets stored or sent.

Index6 bitsBase64Base64URLASCII code
0000000AA0x41
1000001BB0x42
2000010CC0x43
3000011DD0x44
4000100EE0x45
5000101FF0x46
6000110GG0x47
7000111HH0x48
8001000II0x49
9001001JJ0x4A
10001010KK0x4B
11001011LL0x4C
12001100MM0x4D
13001101NN0x4E
14001110OO0x4F
15001111PP0x50
16010000QQ0x51
17010001RR0x52
18010010SS0x53
19010011TT0x54
20010100UU0x55
21010101VV0x56
22010110WW0x57
23010111XX0x58
24011000YY0x59
25011001ZZ0x5A
26011010aa0x61
27011011bb0x62
28011100cc0x63
29011101dd0x64
30011110ee0x65
31011111ff0x66
32100000gg0x67
33100001hh0x68
34100010ii0x69
35100011jj0x6A
36100100kk0x6B
37100101ll0x6C
38100110mm0x6D
39100111nn0x6E
40101000oo0x6F
41101001pp0x70
42101010qq0x71
43101011rr0x72
44101100ss0x73
45101101tt0x74
46101110uu0x75
47101111vv0x76
48110000ww0x77
49110001xx0x78
50110010yy0x79
51110011zz0x7A
52110100000x30
53110101110x31
54110110220x32
55110111330x33
56111000440x34
57111001550x35
58111010660x36
59111011770x37
60111100880x38
61111101990x39
62111110+-0x2B
63111111/_0x2F
padding–=usually omitted0x3D

Two ranges are worth memorizing. Every character from A to P (0 to 15) starts with the bits 00, and every character from w to / (48 to 63) starts with 11. That is enough to decode a character in your head when you are checking a prefix by hand. A worked example of the bit splitting is in how Base64 works.

The alphabet order is not ASCII order. In ASCII, + and / come first, then digits, then uppercase, then lowercase. Sorting Base64 strings therefore does not sort the underlying bytes: +A== (the byte F8) sorts before AA== (the byte 00). If you need encoded values that sort like the raw bytes, use base32hex from RFC 4648 or plain hex.

The URL-safe alphabet

+ and / both have special meaning in URLs. + decodes to a space in query strings and form data, and / separates path segments. Base64URL, defined in section 5 of RFC 4648, keeps indexes 0 to 61 and swaps the last two:

IndexBase64Base64URL
62+-
63/_

Everything else, including the bit layout, is identical, so converting between them is a character replacement plus adding or removing padding. JWTs, many API tokens and file-name-safe identifiers use Base64URL, usually without =. The Base64URL encoder produces it directly. The full comparison is in Base64 vs Base64URL.

The padding character

= (ASCII 0x3D) is not part of the 64-character alphabet and never encodes data. It only fills the last 4-character group when the input length is not a multiple of 3:

  • 1 byte left over: 2 data characters plus ==.
  • 2 bytes left over: 3 data characters plus =.
  • No bytes left over: no padding.

So a padded string always has a length that is a multiple of 4, and you never see ===. Without padding, the length divided by 4 leaves 0, 2 or 3, never 1. The padding guide covers when = may be dropped and how to restore it.

Which characters appear where

A few patterns follow directly from the bit layout. They were checked by brute force over all relevant byte values.

Before == you only see A, Q, g or w. With one byte left over, the second character carries 2 data bits followed by 4 zero bits, so its index is 0, 16, 32 or 48. Before a single =, the third character has 2 zero bits at the end, so it is one of 16 characters: A E I M Q U Y c g k o s w 0 4 8. Anything else in that position means a non-canonical encoding, which strict decoders reject.

Random bytes use all 64 characters equally. Each 6-bit group of random data is uniformly distributed, so encrypted data, keys and compressed files produce a flat character distribution. A skewed distribution is a hint that the data is text or has structure.

ASCII text never puts lowercase g to z, digits, + or / first. The first character of each 4-character group holds the top 6 bits of a byte. For 7-bit ASCII the top bit is 0, so that character is always between A and f (index 0 to 31). In SGVsbG8gd29ybGQh (Hello world!) the group starts are S, b, d and b.

In Base64 of ASCII text, + and / are rare. For bytes below 0x80, + can only appear as the fourth character of a group, when the third byte is > or ~. / can only appear there when that byte is ? or the DEL control character. That is why Hi?> encodes to SGk/Pg== and <b> to PGI+.

Runs of A are zero bytes, runs of / are 0xFF. AAAA is three 00 bytes, //// is three FF bytes. Long stretches of A are typical for sparse binary formats, UTF-16 text (Hello is SABlAGwAbABvAA==) and the length fields at the start of SSH keys. More recognizable patterns are listed in common Base64 prefixes.

Other Base64 alphabets

Several systems kept the idea of 64 characters per 6 bits but chose different characters:

VariantAlphabet in index orderWhere
StandardA-Z a-z 0-9 + /RFC 4648, MIME, PEM, most APIs
URL-safeA-Z a-z 0-9 - _RFC 4648 section 5, JWT
IMAP mailbox namesA-Z a-z 0-9 + ,RFC 3501 modified UTF-7
bcrypt. / A-Z a-z 0-9$2a$, $2b$, $2y$ password hashes
crypt(3). / 0-9 A-Z a-zMD5-crypt $1$, SHA-crypt $5$ and $6$, DES crypt
xxencode+ - 0-9 A-Z a-zOld Unix mail and Usenet
uuencodeASCII 32 to 95 (space to _), often with ` for 0Old Unix mail and Usenet
  • IMAP replaces / with , because / is a common hierarchy separator in mailbox names. A folder called Entwürfe is stored as Entw&APw-rfe.
  • bcrypt moves . and / to the front and keeps letters before digits. Its salts and hashes are Base64 in this alphabet without padding, which is why a standard decoder gives the wrong bytes for them.
  • crypt(3) uses ./0-9A-Za-z, which is ASCII order. It also packs bits starting from the least significant end, so even with a translated alphabet a standard decoder will not reproduce the hash bytes.
  • uuencode and xxencode predate MIME. The uuencode and xxencode tools read and write both.

For encodings with different alphabet sizes, such as Base32, Base58 and Base85, see Base64 vs hex, Base32, Base58 and Base85. Definitions of the terms used here are in the glossary.

FAQ

How many characters are in the Base64 alphabet?

64 characters for data: 26 uppercase letters, 26 lowercase letters, 10 digits, + and /. The padding sign = is a 65th symbol that never carries data.

What is the Base64 value of the letter A?

A stands for index 0, binary 000000. B is 1, Z is 25, a is 26, z is 51, 0 is 52, 9 is 61, + is 62 and / is 63.

Which characters does Base64URL change?

Only two: + (index 62) becomes - and / (index 63) becomes _. Padding is usually dropped as well. Convert with Base64 to Base64URL.