Base64 to Base62 Converter
Convert Base64 to Base62 and Base62 to Base64 online. Lossless bi-directional encoding converter with BigInt precision for any payload size.
About
Base64 encodes binary data into 64 printable ASCII characters (A - Z, a - z, 0 - 9, +, /) plus the padding character =. Base62 uses the same alphanumeric set but drops the two non-alphanumeric symbols, producing output that is URL-safe, filename-safe, and safe for use inside double-quoted JSON strings without escaping. The trade-off is a roughly 1 - 2% longer output because log2(62) ≈ 5.954 bits per character versus log2(64) = 6 bits per character. Getting the conversion wrong silently corrupts payloads. A single misplaced character in either alphabet produces garbage bytes on decode.
This tool performs lossless, bi-directional conversion by treating the raw byte payload as an arbitrary-precision integer and re-encoding it in the target radix. A one-byte length prefix is stored so the original byte count survives the round-trip. The implementation uses native BigInt arithmetic. Note: this tool approximates constant-time performance for inputs under 100 kB. Beyond that, BigInt division chains grow quadratically.
Formulas
The conversion treats the input's decoded byte array as a base-256 big integer N, then re-encodes it digit-by-digit in the target base.
N = nโ1โi=0 bi โ 256nโ1โi
where bi is the i-th byte. The target encoding repeatedly extracts remainders:
dk = N mod R, then N = N โ dkR
where R = 62 (or 64) is the target radix and each dk maps to a character in the target alphabet. Digits are collected least-significant first, then reversed. A single length-prefix byte stores the original payload size modulo 256 to resolve leading-zero ambiguity during round-trip conversion.
Reference Data
| Property | Base64 (RFC 4648) | Base62 |
|---|---|---|
| Alphabet size | 64 | 62 |
| Characters | A-Z a-z 0-9 + / | 0-9 A-Z a-z |
| Padding | = (up to 2) | None |
| Bits per character | 6.000 | 5.954 |
| Expansion ratio (vs binary) | 4/3 ≈ 1.333 | ≈ 1.344 |
| URL-safe | No (+ and / need encoding) | Yes |
| Filename-safe | No | Yes |
| JSON-safe (no escaping) | No (/ may be escaped) | Yes |
| Used in | MIME, PEM, JWT, Data URIs | Short URLs, ID hashing, Redis keys |
| Case-sensitive | Yes | Yes |
| Common implementations | btoa/atob, OpenSSL | Custom libraries, Hashids |
| Padding overhead (worst case) | 2 bytes | 0 bytes |
| Encoding standard | RFC 4648 ยง4 | No formal RFC |
| Base64url variant | A-Z a-z 0-9 - _ | N/A |
| Typical use: 16-byte UUID | 24 chars | 22 chars |
| Typical use: 32-byte hash | 44 chars | 43 chars |
| Decoding complexity | O(n) | O(n2) via BigInt |
| Sortable output | No (alphabet order differs) | Yes (lexicographic = numeric) |