Base62 Encode String
Encode and decode strings to Base62 format online. Fast, client-side Base62 converter using alphanumeric characters 0-9, A-Z, a-z.
About
Base62 encoding maps arbitrary binary data onto a 62-character alphabet: 0-9, A - Z, a - z. Unlike Base64, it avoids +, /, and = padding, producing URL-safe, filename-safe output without percent-encoding overhead. This matters in systems where non-alphanumeric characters cause parsing failures: REST path segments, short-link services, database keys with collation constraints, and distributed trace IDs. An incorrect encoding choice can silently corrupt data when it passes through middleware that strips or escapes special characters.
This tool converts UTF-8 strings to their Base62 representation by treating the byte sequence as a big-endian unsigned integer and performing repeated modular division by 62. The result is deterministic and reversible. Limitation: because the algorithm operates on arbitrary-precision integers, inputs beyond approximately 100 KB will incur noticeable latency. For bulk binary payloads, a chunked approach or Base64 with URL-safe variant may be more practical.
Formulas
Base62 encoding treats the input byte array as a single big-endian unsigned integer N and converts it to base 62 using the alphabet A = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".
where bi is the i-th byte of the UTF-8 encoded input and n is the total byte count. The encoded digits dk are extracted by repeated division:
The output string is the sequence of A[dk] characters, reversed (most-significant digit first). Decoding reverses the process: each character maps to index dk, accumulated as N = N โ 62 + dk, then N is converted back to bytes.
The expansion ratio is log(256)log(62) ≈ 1.344, meaning each input byte produces roughly 1.344 Base62 characters.
Where: N = integer representation of input bytes, bi = i-th byte value (0 - 255), A = Base62 alphabet string, dk = k-th digit in base 62.
Reference Data
| Encoding | Alphabet Size | Characters Used | URL Safe | Padding | Expansion Ratio (approx.) | Common Use Cases |
|---|---|---|---|---|---|---|
| Base62 | 62 | 0-9, A - Z, a - z | Yes | None | 1.37ร | Short URLs, trace IDs, tokens |
| Base64 | 64 | A - Z, a - z, 0-9, +/ | No | = | 1.33ร | Email (MIME), data URIs |
| Base64url | 64 | A - Z, a - z, 0-9, -_ | Yes | Optional | 1.33ร | JWT, URL parameters |
| Base58 | 58 | Base62 minus 0, O, I, l | Yes | None | 1.38ร | Bitcoin addresses, IPFS |
| Base32 | 32 | A - Z, 2-7 | Yes | = | 1.60ร | TOTP secrets, Crockford IDs |
| Base16 (Hex) | 16 | 0-9, A - F | Yes | None | 2.00ร | Hash digests, MAC addresses |
| Base85 (Ascii85) | 85 | ASCII 33 - 117 | No | None | 1.25ร | PDF streams, PostScript |
| Base36 | 36 | 0-9, A - Z | Yes | None | 1.55ร | Case-insensitive short IDs |
| Base91 | 91 | ASCII printable subset | No | None | 1.23ร | Compact binary-to-text |
| Z85 (ZeroMQ) | 85 | Printable ASCII subset | Partial | None | 1.25ร | ZeroMQ frames, CurveZMQ |
| Base128 | 128 | Full 7-bit ASCII | No | None | 1.14ร | Protobuf varints |
| UUencode | 64 | ASCII 32 - 95 | No | Length byte | 1.37ร | Legacy Unix email |