UTILS.
100% in-browser
🔢

Base62 Encode & Decode

Convert integers or byte strings to and from compact URL-safe Base62 (0-9A-Za-z), with BigInt support and a GMP alphabet variant, all in-browser.

— output appears here —

About this tool

The Base62 tool encodes numbers and byte strings into the compact 62-symbol alphabet 0-9A-Za-z and decodes them back. Base62 is popular for short IDs, URL slugs, and shortened links because it stays URL-safe without the +, / or = characters that Base64 uses. All conversion runs locally in your browser with JavaScript BigInt, so arbitrarily large values are exact and nothing is uploaded.

Integer mode treats the input as an arbitrary-precision integer (decimal, or 0x-prefixed hex): encoding repeatedly divides by 62 and prepends alphabet[remainder], and decoding computes Σ alphabet.indexOf(ch)·62^position. Byte mode treats the input bytes (UTF-8 text or hex) as one big-endian bignum and applies the same base-62 conversion, but it also preserves leading zero bytes Bitcoin-Base58 style: each leading 0x00 byte becomes one leading '0' character so round-trips are lossless.

The standard alphabet orders digits, then uppercase, then lowercase (0-9A-Za-z). Some libraries — notably ones built on GMP — order digits, lowercase, then uppercase (0-9a-zA-Z), which produces different output for the same value; the alphabet toggle lets you match whichever your system uses. Pick the direction, the integer or bytes mode, the input format for bytes, and the alphabet variant.

Frequently asked questions

What is the difference between integer and bytes mode?
Integer mode converts a single arbitrary-precision number (decimal or 0x-hex) to a Base62 string and back to a decimal integer. Bytes mode converts a sequence of bytes (from UTF-8 text or hex) as a big-endian bignum, and preserves leading zero bytes as leading alphabet-zero characters so binary data round-trips exactly.
Why are there two alphabets?
The standard alphabet is 0-9A-Za-z (uppercase before lowercase). GMP-based libraries use 0-9a-zA-Z (lowercase before uppercase). The same value encodes differently under each, so the toggle lets you interoperate with whichever ordering your other tools expect.
How large a number can it handle?
Any size. The tool uses JavaScript BigInt, so there is no 2^53 precision limit — you can encode and decode integers and byte strings of arbitrary length exactly, which is essential for hashes, UUIDs, and long identifiers.
How are leading zeros handled in bytes mode?
Each leading 0x00 byte is encoded as one leading alphabet-zero character (like Base58's leading '1'). On decode, each leading alphabet-zero character restores one 0x00 byte, so encoding then decoding returns the exact original byte sequence.

More tools