Upload a file
  1. base64hub
  2. Other bases
  3. Base62

Base62 Encoder and Decoder Online

Type text to get Base62, the digits-and-letters encoding behind many short URLs and IDs. Base62 has no single standard alphabet order, so pick the one your library uses: 0-9 A-Z a-z or 0-9 a-z A-Z.

Free no sign-up, no limits Local nothing uploaded 2 alphabets 0-9A-Za-z and 0-9a-zA-Z Updated Oct 27, 2026
Input 0Bytes 0 BOutput 0

Processed in your browser. This page cannot send your data anywhere – how we know

How to encode and decode Base62

  1. Type or paste text into Input · Text. The Base62 string appears in Output · Base62.
  2. Set Alphabet under the output to match the system you are talking to: 0-9 A-Z a-z or 0-9 a-z A-Z.
  3. For a numeric ID, change From to Integer (big number) and type the number in decimal. For raw bytes, choose Hex or Base64.
  4. To decode, click Base62 → Text in the direction toggle. The Alphabet choice then sits under the input, and it must be the same one used for encoding.

Two alphabet orders with different results

Base62 has no RFC, and the 62 characters are ordered two ways in the wild. This converter offers both:

AlphabetValue of AValue of aHello1000000 as a number
0-9 A-Z a-z10365TP3P3v4C92
0-9 a-z A-Z36105tp3p3V4c92

The first order follows ASCII order, so encoded strings of equal length sort the same way as the numbers. GMP uses it for bases 37 to 62. The second order matches what you get when you extend hexadecimal’s lower-case a-f; some libraries call it the “inverted” alphabet.

Each output is the other with the case of every letter flipped. That makes the mistake easy to miss: decoding 5tp3p3V with the wrong order succeeds, but gives the bytes 4e 08 14 29 1d instead of Hello. If a decoded value looks like garbage, try the other order before suspecting the data.

Base62 for short IDs and URLs

URL shorteners and ID schemes use Base62 because every character is safe in a URL path, a file name and a double-click selection, and the result is short. A database ID is a number, so encode it from Integer (big number):

DecimalBase62 (0-9A-Za-z)
12521
3843zz
3844100
10000004C92
1234567898M0kX

Seven characters cover numbers up to 62^7 − 1, about 3.5 trillion. For a random ID, encode random bytes: a 16-byte UUID becomes 21 or 22 characters, against 32 in hex.

Short sequential IDs reveal how many records exist and are easy to guess. If that matters, encode random bytes rather than a counter.

How Base62 handles bytes and leading zeros

Because 62 is not a power of two, Base62 cannot map bit groups to characters. It reads the input as one big-endian number and converts that number to base 62. Leading zero bytes would disappear, so this tool writes one 0 digit for each of them: the bytes 00 00 encode as 00, and 00 ff as 047.

Libraries differ here too. Many encode only the number and drop leading zeros, and fixed-width formats pad to a set length instead. If the receiving side expects a fixed width, left-pad the output with 0. The big-number approach also has a cost that grows with the square of the input length, so this tool limits Base62 input to 64 KB.

Base62 in Python

Python has no Base62 in the standard library. For integer IDs, the conversion is a few lines:

ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

def b62encode(n: int) -> str:
    if n == 0:
        return ALPHABET[0]
    out = ""
    while n:
        n, r = divmod(n, 62)
        out = ALPHABET[r] + out
    return out

def b62decode(s: str) -> int:
    n = 0
    for ch in s:
        n = n * 62 + ALPHABET.index(ch)
    return n

b62encode(1000000)    # '4C92'
b62decode("8M0kX")    # 123456789

Swap the two letter blocks in ALPHABET for the other order. For bytes, convert with int.from_bytes(data, "big") first. More on byte handling in Python.

FAQ

What is the Base62 alphabet?

The ten digits plus the 26 upper-case and 26 lower-case letters: 62 characters, nothing else. The digits always come first, but libraries disagree on whether upper case (0-9A-Za-z) or lower case (0-9a-zA-Z) comes next.

What is the difference between Base62 and Base64?

Base64 adds + and / (or - and _) and = padding, and maps fixed 6-bit groups. Base62 uses only letters and digits, so it needs no escaping anywhere, but 62 is not a power of two, so it has to treat the data as one big number. The output is about 1% longer than Base64.

How do I encode a number to Base62?

Set From to Integer (big number) and type the decimal number. 1000000 becomes 4C92 with the default alphabet. Encoding the number as text would encode its digit characters instead.

Is Base62 case-sensitive?

Yes. A and a are different digits, worth 10 and 36 in the default order. A system that lowercases URLs or IDs will corrupt Base62 strings; use Base36 if case can get lost.