Base62 Encoder/Decoder

URL-safe alphanumeric encoding — 0-9, A-Z, a-z only

Encode and decode Base62 using only digits and letters, with no symbols to escape in URLs. Convert large integers to short IDs or round-trip UTF-8 bytes through big-integer base conversion, all in your browser with full edge-case handling. It runs free in your browser on Gera Tools, with nothing uploaded.

Last updated Source: Gera Tools

What is Base62 good for?

Base62 uses only the 62 characters that are letters and digits, so the output never contains symbols that must be escaped in a URL, filename, or HTML attribute. That makes it a popular choice for short link slugs and compact public IDs derived from large database keys.

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:

  1. In integer mode the input number is divided by 62 repeatedly; each remainder picks one character, read most-significant first. JavaScript BigInt is used so arbitrarily large IDs encode exactly.
  2. 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 0 so the value round-trips.
  3. 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,000 in Base62 is 4C92 — 4 characters. In hexadecimal it would be F4240 — 5 characters. In Base36 it would be LFLS — 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 abc from ABC as 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

EncodingCharactersURL-safe without escapingCompactHuman-error resistant
Base620-9A-Za-zYesHighModerate
Base581-9A-Za-z minus I, O, lYesHighHigh
Base64urlA-Za-z0-9-_YesHighestLower
Hex0-9a-fYesLowLow

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.