Base62 encoding represents data using 26 lowercase letters (a-z), 26 uppercase letters (A-Z), and 10 digits (0-9), totaling 62 characters. It is used to generate short URL codes.
Why Base62 suits short URLs can be shown with numbers. A 6-character Base62 code can represent 62^6, roughly 56.8 billion unique patterns. With 7 characters, that jumps to about 3.5 trillion.
One implementation used by short URL services assigns a unique integer ID to each URL and converts that ID to Base62 to produce the short code. For example, with the character order 0-9, a-z, A-Z, ID 12345 converts to "3d7" (3 characters). Codes grow longer as IDs increase, but values up to roughly 56.8 billion still fit within 6 characters.
Base64 is a similar scheme, but it includes "+" and "/", which can be problematic in URLs. The alphanumeric characters used by Base62 are among the unreserved characters that RFC 3986 allows in URLs as-is, so no additional encoding is needed.
Implementing Base62 is a base-10 to base-62 conversion, achievable in a few lines of code in most languages. One caveat: converting sequential IDs directly to Base62 makes codes predictable, which is a security concern. Countermeasures include combining the ID with a hash function or generating random strings.