Base62 encodes data using the 62 characters 0-9, A-Z, and a-z — every alphanumeric character and nothing else. With no symbols to escape, the output drops cleanly into URLs, filenames, and HTML attributes, which is why it is a favourite for short link slugs and compact IDs. This tool encodes integers or UTF-8 bytes to Base62 and decodes them back, all in your browser.
How it works
Base62 is positional base conversion against the alphabet 0-9A-Za-z:
- In integer mode the input number is divided by 62 repeatedly; each remainder picks one character, read most-significant first. JavaScript
BigIntis used so arbitrarily large IDs encode exactly. - In bytes mode the input bytes are treated as one big-endian integer and converted the same way, with each leading zero byte emitted as a leading
0so the value round-trips. - Decoding accumulates each character’s value back into the integer, then either prints the number (integer mode) or rebuilds the bytes (bytes mode).
Edge cases are handled explicitly: the number 0 encodes to a single 0, empty input yields empty output, and any character outside the alphabet is rejected by name.
Why Base62 for short URLs?
Short URL services need IDs that are compact, URL-safe without encoding, and case-sensitive to maximise the number of unique slugs per character. Base62 checks all three boxes:
- Compact:
1,000,000in Base62 is4C92— 4 characters. In hexadecimal it would beF4240— 5 characters. In Base36 it would beLFLS— still 4, but only 36 symbols vs 62, meaning the same 4-character space holds far fewer IDs. - No escaping needed: unlike Base64 (which uses
+and/) or Base85 (which uses many punctuation marks), Base62’s alphanumeric-only output never needs percent-encoding in a URL. - Case-sensitive: distinguishing
abcfromABCas different slugs doubles the slug space compared to a case-insensitive scheme at the same character length.
Worked example
For example, 1000000 encodes to 4C92 in Base62. Decoding 4C92 in integer mode returns 1000000. A 6-character Base62 slug can represent up to 62⁶ = 56,800,235,584 unique IDs — more than enough for most short-link databases.
Base62 vs alternatives
| Encoding | Characters | URL-safe without escaping | Compact | Human-error resistant |
|---|---|---|---|---|
| Base62 | 0-9A-Za-z | Yes | High | Moderate |
| Base58 | 1-9A-Za-z minus I, O, l | Yes | High | High |
| Base64url | A-Za-z0-9-_ | Yes | Highest | Lower |
| Hex | 0-9a-f | Yes | Low | Low |
If you need a checksum or want to reduce human transcription errors (I vs l vs 1, 0 vs O), prefer Base58. If you want the absolute shortest output and the recipient decodes programmatically, use Base64url. Base62 hits a practical middle ground with a clean, intuitive character set.