Number to Base36
1234567890
kf12oi
The same result as (1234567890).toString(36) in JavaScript.
Convert numbers or text to Base36 (0–9 and a–z) and back. Case-insensitive, URL-safe and compact, with no size limit on numbers.
1234567890
kf12oi
The same result as (1234567890).toString(36) in JavaScript.
ZZ
1295
z is 35, so zz = 35 × 36 + 35 = 1295. Uppercase and lowercase decode the same.
Hi
eax
The bytes 48 69 form the number 18537 = 14 × 1296 + 10 × 36 + 33, written e, a, x.
Base36 writes numbers using the 10 digits and the 26 letters of the alphabet: 0–9 then a–z. It is the largest base that works in one letter case, so abc and ABC mean the same thing. That makes Base36 a good fit for IDs that people read, type or say out loud, and for systems that ignore letter case, such as domain names, some file systems and some databases.
Base36 is mostly used for numbers, but this tool can also encode text and bytes.
Each position is worth 36 times the position to its right. The digits are 0–9 for values 0–9 and a–z for values 10–35:
| Value | Digit | Value | Digit | Value | Digit |
|---|---|---|---|---|---|
| 0–9 | 0–9 | 18 | i | 27 | r |
| 10 | a | 19 | j | 28 | s |
| 11 | b | 20 | k | 29 | t |
| 12 | c | 21 | l | 30 | u |
| 13 | d | 22 | m | 31 | v |
| 14 | e | 23 | n | 32 | w |
| 15 | f | 24 | o | 33 | x |
| 16 | g | 25 | p | 34 | y |
| 17 | h | 26 | q | 35 | z |
To convert 1234567890, divide by 36 repeatedly and keep the remainders: 18, 24, 2, 1, 15, 20. Written from last to first as digits, that is k f 1 2 o i, so the answer is kf12oi.
| Base36 | Base62 | |
|---|---|---|
| Characters | 0–9 a–z | 0–9 A–Z a–z |
| Case-sensitive | No | Yes |
| Values in 6 characters | 2,176,782,336 | 56,800,235,584 |
| Best for | IDs people type or say; case-insensitive systems | The shortest possible URL-safe IDs |
Base36 IDs are a little longer, but they survive anything that changes letter case.
JavaScript supports Base36 natively for normal numbers:
(1234567890).toString(36); // "kf12oi"parseInt('kf12oi', 36); // 1234567890 // A short random ID (not for secrets)Math.random().toString(36).slice(2, 10); // e.g. "4fzyo82m"Precision warning: JavaScript numbers are exact only up to 253 − 1 (9,007,199,254,740,991). Above that, toString(36) and parseInt silently return wrong results. Use BigInt for large values, as this tool does:
function toBase36(n) { n = BigInt(n); let out = ''; do { out = '0123456789abcdefghijklmnopqrstuvwxyz'[Number(n % 36n)] + out; n /= 36n; } while (n > 0n); return out;} toBase36('18446744073709551615'); // "3w5e11264sgsf" (2^64 - 1)Math.random().toString(36) is handy for test data but is not cryptographically secure. For tokens, use crypto.getRandomValues().
# Python: decoding is built inint('kf12oi', 36) # 1234567890 def to_base36(n: int) -> str: digits = '0123456789abcdefghijklmnopqrstuvwxyz' out = '' while True: n, r = divmod(n, 36) out = digits[r] + out if n == 0: return out// PHP: base_convert() works on strings, but loses precision on large numbersbase_convert('1234567890', 10, 36); // "kf12oi" // Exact for any size with GMPgmp_strval(gmp_init('1234567890', 10), 36); // "kf12oi"/comments/abc123/.Date.now().toString(36) gives an 8-character, sortable string.parseInt(x, 36) returns a slightly wrong number
The value is larger than 2⁵³ − 1, so JavaScript lost precision. Use BigInt (see the code above). This tool uses BigInt and gives exact results for any size.
PHP base_convert() gives a wrong result for long IDs
base_convert() works with floating point internally and loses precision on large numbers. Use gmp_strval(gmp_init($n, 10), 36) instead.
"Not a valid Base36 character"
Base36 only uses 0–9 and a–z. Remove spaces inside the value, dashes and punctuation. Letter case does not matter.
Leading zeros are lost when converting text
In Number mode, leading zeros carry no value (007 is 7). In Text / bytes mode, leading zero bytes are kept as leading 0 characters, so the original bytes come back exactly.
No. Base36 uses one set of 26 letters, so ABC and abc decode to the same value. Lowercase is the usual convention.
Set Input to Number, choose Encode and type the number. In JavaScript you can also use n.toString(36) for numbers below 2⁵³.
It is 10 digits plus 26 letters: every character you can type without a shift key or symbol. It is the largest base that does not depend on letter case.
There is no practical limit. The tool uses arbitrary-precision integers (BigInt), so even numbers with hundreds of digits convert exactly.
Base62 gives shorter IDs, but they are case-sensitive. Choose Base36 when IDs will be typed by people or pass through systems that may change letter case.
Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.
Tip: press Ctrl D to bookmark dev247.