Base62 Encoder & Decoder

Convert text or a big integer into Base62 — the URL-safe, all-alphanumeric encoding behind short links and compact IDs — and decode it back. It uses exact big-integer math so even very long values are precise, and lets you pick the alphabet ordering. Everything runs locally as you type.

How to use the Base62 Encoder & Decoder

Choose Encode or Decode, tell the tool whether your input is Text or an Integer, and type or paste. The result updates live and Copy output grabs it. When encoding text, the characters are first turned into their UTF-8 bytes, those bytes are read as one big number, and that number is written in base 62 using only the digits 0-9 and the letters A-Z and a-z. When encoding an integer, the whole number you type is converted directly — there is no size limit because the math is done with exact big integers, so a 40-digit ID converts without rounding.

Decoding reverses the process: a Base62 string becomes a big number, and then either the original integer (in Integer mode) or the original bytes decoded as UTF-8 text (in Text mode). The Alphabet option selects the ordering of the 62 symbols. The default places digits first, then uppercase, then lowercase; the GMP ordering used by some libraries places digits, then lowercase, then uppercase. Both encode the same values, but a string encoded with one ordering must be decoded with the same ordering, so match it to whatever produced your data.

If you decode a string containing a character that is not in the chosen alphabet, the tool reports it rather than guessing. Everything is computed in your browser, so it is instant and nothing you enter is uploaded.

Why Base62 powers short links and IDs

Base62 represents data using sixty-two symbols: the ten digits and the twenty-six letters of the alphabet in both cases, 0-9, A-Z, and a-z. Its appeal is that every one of those characters is a letter or a digit — there is no +, /, =, hyphen, or underscore as you find in Base64 or Base64url. That makes a Base62 string safe to drop into almost any context without escaping: it travels cleanly in a URL path, a hostname label, a filename, a database key, or a double-clickable token, because nothing in it has special meaning to those systems. This is exactly why URL shorteners and ID generators reach for it — a short code like aZ3kQ is compact, copy-pasteable, and never needs encoding.

Mechanically, Base62 is just positional notation in a larger base, the same idea as hexadecimal taken further. To encode a number you repeatedly divide by 62 and map each remainder to a symbol, building the string from least significant digit to most; to decode you run Horner's method, multiplying the running total by 62 and adding each symbol's value. The catch is that the numbers involved are often enormous — a 16-byte UUID is a 39-digit decimal number, far beyond what a normal 64-bit integer or a JavaScript Number can hold without losing precision. Correct Base62 therefore requires arbitrary-precision arithmetic, which is why doing it casually with floating-point math silently corrupts large values. Using exact big integers keeps every digit intact no matter how long the input.

Encoding text rather than a number adds one conceptual step: the text is converted to bytes (here via UTF-8), and the byte sequence is interpreted as a single big-endian integer before being written in base 62. This is how you turn an arbitrary string into a purely alphanumeric token. One subtlety worth knowing is that pure base conversion does not record leading zero bytes — a value is a value regardless of how many zeros sit in front of it — so encodings meant to preserve exact byte counts (like Base58Check for cryptocurrency addresses) add explicit handling for that, whereas plain Base62 does not. For ordinary text and identifiers this never comes up. The other thing to watch is that there is no single official Base62 alphabet ordering; the common choice puts digits first, but some libraries order the letters differently, and a string only round-trips if it is decoded with the same ordering it was encoded with. Pick the matching alphabet and Base62 is a clean, compact, escaping-free way to move numbers and short strings through systems that only tolerate letters and digits.

Common use cases

  • Short URLs. Encode a numeric ID into a compact alphanumeric slug for a short link.
  • Compact IDs. Shorten a large integer or UUID-sized number into a tidy token.
  • URL-safe tokens. Turn a string into letters and digits only, with nothing to escape.
  • Decoding data. Recover the original number or text from a Base62 code.

Frequently asked questions

Why use Base62 instead of Base64?

Base62 uses only letters and digits, so it needs no special characters like + / or =. That makes it safe in URLs, filenames, and identifiers without any escaping, at the cost of being slightly less compact than Base64.

Does it handle very large numbers correctly?

Yes. All conversion uses exact big-integer arithmetic, so even numbers far larger than 64 bits — such as a UUID expressed as a decimal — encode and decode without any loss of precision.

Why are there two alphabets?

There is no single standard ordering of the 62 symbols. The default is digits, uppercase, lowercase; the GMP ordering is digits, lowercase, uppercase. A string must be decoded with the same alphabet it was encoded with.

Will leading zero bytes survive a round trip?

Plain Base62 encodes the numeric value, which does not record leading zero bytes. Ordinary text and integers are unaffected; schemes needing exact byte counts use a variant like Base58Check that adds explicit leading-zero handling.