Base62 converter

What is a Base62 Converter?

Base62 writes numbers using 62 symbols: the digits 0 to 9, uppercase A to Z and lowercase a to z. Because it uses only letters and digits, Base62 strings are safe in URLs, file names and HTML IDs without any escaping. It is the classic encoding behind URL shorteners, which turn an auto-increment database ID into a short slug.

How to use it

  1. Enter a non-negative integer to encode it to Base62.
  2. Or enter a Base62 string to decode it back to a number.

How it works

Encoding repeatedly divides the number by 62 and maps each remainder to a character, exactly as you would convert decimal to hexadecimal but with base 62. Decoding multiplies back: each character's value times 62 to the power of its position.

Example

The number 125 is 2 × 62 + 1, so with the alphabet 0-9A-Za-z it becomes 21. A larger ID such as 1000000 becomes 4C92, only four characters. Seven Base62 characters can represent more than 3.5 trillion values.

Practical notes

  • Alphabet order matters. Some libraries use 0-9a-zA-Z instead of 0-9A-Za-z. Both are valid, but they produce different strings, so use the same order everywhere.
  • Sequential IDs are guessable. Encoding an auto-increment ID does not hide it. If links must not be enumerable, use random IDs such as NanoID instead.
  • Large numbers. JavaScript numbers lose precision above 2^53. For bigger values, encode them as BigInt or as strings.

Frequently Asked Questions

What is Base62 used for?

Mostly for short URLs and compact identifiers, because the output contains only letters and digits and is safe everywhere.

Is Base62 the same as Base64 without symbols?

Not exactly. Base64 encodes bytes in 6-bit groups, while Base62 here converts a whole number to base 62. The outputs are not interchangeable.

Why do two Base62 tools give different results?

They probably use a different alphabet order, such as lowercase before uppercase. Both are correct, but you must decode with the same alphabet you encoded with.

Can Base62 IDs be guessed?

If they come from sequential numbers, yes. Use random IDs if you need links that cannot be enumerated.