What is Base 62?
Base 62 is the algorithm used by most URL shorteners to generate custom short links. To answer how it works, the first question we need to answer is: what are bases?
What is a base?
When counting up, the base is the number of numbers that you count before add another digit.
We all get taught base 10 in school. This means that once you count past ‘9’, you add a ‘1’ to the left of your number, and start over again from ‘0’.
What other bases are popular?
Binary (base 2) are just 1’s and 0’s, and hexadecimal (base 16) are both used heavily in computer science.
When a base is greater than 10, we use letters to represent the digits. So for hexadecimal, we use the digits 0-9, followed by the letters A-F. F would the number 15 (in base 10), and 10 would be the number 16.
What is base 62?
Base 62 consists of all the normal numbers 0-9, plus all the uppercase letters A-Z, and all the lowercase letters a-z. That’s for a total number of symbols of 10 + 26 + 26 = 62.
This means that long numbers can be represented by a short few letters. For example, the base 10 number
Base 10: 1213542312 => Base 62: 1K7tn6
URL shorteners represent links internally using Base 10, counting up from 0, but display the shortened Base 62 URL on the outside.
That is how base 62 works!