Skip to content

↑↓ navigate ↵ open Esc close Search runs locally

Base36 Encode & Decode Online (Numbers and Text)

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.

  • Runs in your browser
  • Nothing is uploaded
  • Free, no sign-up
0 BUTF-8
Base36
Runs in your browser. Nothing is uploaded. Tip: drop a file onto the left box

How to use the Base36 tool#

  1. Choose Encode or Decode at the top of the tool.
  2. Set Input to Number to convert a whole number, or to Text / bytes to encode text.
  3. Pick lowercase or UPPERCASE output with Case. Decoding accepts both.
  4. Type or paste into the left box, then copy the result.

Examples#

Number to Base36

Input
1234567890
Output
kf12oi

The same result as (1234567890).toString(36) in JavaScript.

Base36 back to a number

Input
ZZ
Output
1295

z is 35, so zz = 35 × 36 + 35 = 1295. Uppercase and lowercase decode the same.

Encode text

Input
Hi
Output
eax

The bytes 48 69 form the number 18537 = 14 × 1296 + 10 × 36 + 33, written e, a, x.

What is Base36?#

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.

How Base36 works#

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:

ValueDigitValueDigitValueDigit
0–90–918i27r
10a19j28s
11b20k29t
12c21l30u
13d22m31v
14e23n32w
15f24o33x
16g25p34y
17h26q35z

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 vs Base62#

Base36Base62
Characters0–9 a–z0–9 A–Z a–z
Case-sensitiveNoYes
Values in 6 characters2,176,782,33656,800,235,584
Best forIDs people type or say; case-insensitive systemsThe shortest possible URL-safe IDs

Base36 IDs are a little longer, but they survive anything that changes letter case.

Base36 in JavaScript#

JavaScript supports Base36 natively for normal numbers:

javascript
(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:

javascript
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().

Base36 in other languages#

python
# 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
// 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"

Where Base36 is used#

  • Reddit post and comment IDs, which appear in URLs such as /comments/abc123/.
  • Short codes and coupons that people type by hand.
  • Compact timestamps: Date.now().toString(36) gives an 8-character, sortable string.
  • Case-insensitive keys in file names, subdomains and older databases.

Common errors and fixes#

  • 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.

Frequently asked questions#

Is Base36 case-sensitive?

No. Base36 uses one set of 26 letters, so ABC and abc decode to the same value. Lowercase is the usual convention.

How do I convert a number to Base36?

Set Input to Number, choose Encode and type the number. In JavaScript you can also use n.toString(36) for numbers below 2⁵³.

Why 36?

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.

What is the largest number this tool can convert?

There is no practical limit. The tool uses arbitrary-precision integers (BigInt), so even numbers with hundreds of digits convert exactly.

Base36 or Base62 for short IDs?

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.

Your next tool is one search away.

Free, private developer tools that run in your browser. No signup, nothing uploaded, no waiting.

Browse all tools

Tip: press Ctrl D to bookmark dev247.