User Rating 0.0
Total Usage 0 times
0 characters
Is this tool helpful?

Your feedback helps us improve.

About

Base62 encoding maps binary data onto a 62-character alphabet: 0-9, A - Z, a - z. It produces URL-safe, filename-safe output without special characters - unlike Base64, which emits +, /, and =. This tool reverses the encoding: it takes a Base62 string and recovers the original byte sequence. Incorrect decoding silently corrupts data. A single invalid character in the input invalidates the entire output because Base62 is a positional numeral system in base 62, and every digit affects every byte of the result.

The decoder uses arbitrary-precision arithmetic (BigInt) internally, so it handles inputs of any practical length without overflow. Output can be rendered as UTF-8 text, ASCII, or hexadecimal bytes. Note: if the original data was not valid UTF-8, the text output may contain replacement characters (U+FFFD). Use hex mode to inspect raw bytes in that case.

base62 decode encoder string decoder base conversion encoding

Formulas

Base62 treats the input string as a number in base 62. Each character maps to a digit value d in the range [0, 61]. The decoded integer N is computed by Horner's method:

N = n1i=0 di 62n1i

Iteratively this becomes the loop: N = N × 62 + di for each character left to right. The resulting integer N is then converted to a big-endian byte array by repeated division by 256:

bytek = N mod 256 , N = N256

The alphabet mapping is: digits 0-9 values 0-9, uppercase A - Z 10-35, lowercase a - z 36-61. Information density is log2(62) 5.954 bits/char, compared to 6.0 bits/char for Base64.

Where N = decoded integer, di = digit value of the i-th character, n = length of the encoded string, and bytek = the k-th output byte (collected in reverse order).

Reference Data

EncodingAlphabet SizeCharacters UsedURL SafePaddingEfficiency (bits/char)Common Use
Base62620-9 A - Z a - zYesNone5.95Short URLs, ID generation
Base6464A - Z a - z 0-9 + /No=6.00Email (MIME), data URIs
Base64url64A - Z a - z 0-9 - _YesOptional6.00JWT, URL parameters
Base58581-9 A - H J - N P - Z a - k m - zYesNone5.86Bitcoin addresses
Base36360-9 a - zYesNone5.17Case-insensitive IDs
Base3232A - Z 2-7Yes=5.00TOTP secrets, Crockford IDs
Base16 (Hex)160-9 A - FYesNone4.00Color codes, checksums
Base85 (Ascii85)85! - uNo~>6.41PDF, PostScript
Base9191Printable ASCII subsetNoNone6.51Compact binary-to-text
Base128128Full 7-bit ASCIINoNone7.00Protobuf varints
Base256256All byte valuesNoNone8.00Raw binary storage
Hexadecimal160-9 a - fYesNone4.00MAC addresses, hashes
Octal80-7YesNone3.00Unix permissions
Binary20 1YesNone1.00Bitwise debugging

Frequently Asked Questions

Exactly 62 characters: digits 0 - 9 (values 0-9), uppercase letters A - Z (values 10-35), and lowercase letters a - z (values 36-61). Any character outside this set - including +, /, =, spaces, or Unicode - will cause a decoding error. The decoder validates input before processing and reports the position of the first invalid character.
Base64 uses +, /, and the padding character =, all of which have reserved meanings in URLs, filenames, and XML. Base62 restricts itself to purely alphanumeric characters. This means a Base62 string can be embedded directly in a URL path segment, used as a filename, or placed in a JSON value without any escaping. The trade-off is slightly lower information density: 5.954 bits/char vs. 6.0 bits/char.
JavaScript's Number type is a 64-bit IEEE 754 float, which can only represent integers exactly up to 253 1 (about 9 × 1015). A Base62 string of just 10 characters can represent values up to 6210 8.4 × 1017, which already exceeds safe integer range. BigInt provides arbitrary-precision integer arithmetic, so the decoder handles strings of any length without silent precision loss.
The decoder recovers the exact byte sequence. When rendered as UTF-8 text, invalid byte sequences are replaced with the Unicode replacement character U+FFFD (‘�’). To inspect the raw bytes without interpretation, switch the output mode to Hex. This shows each byte as a two-character hexadecimal value (e.g., 00 for a null byte, FF for byte 255).
No. Unlike Base64 (RFC 4648) or Base32 (RFC 4648), Base62 has no formal standard. The most common convention uses the alphabet 0-9A - Za - z with digit values in that order, which this tool follows. Some implementations swap the positions of uppercase and lowercase blocks. If your encoded data uses a different alphabet order, the decode will produce incorrect output. Always verify the alphabet convention with the encoder.
Yes. In Base62 as a positional system, a leading 0 character has digit value 0. Mathematically, leading zeros do not change the integer N. However, some Base62 implementations use leading 0 characters to represent leading null bytes (0x00) in the original data, similar to Base58's convention. This decoder treats the input as a pure number, so leading zeros are absorbed. If your encoder preserves leading null bytes via leading zeros, the output may be shorter than expected.