Base62 encoder and decoder — letters and digits only

Encode text into Base62, which uses only the 62 digits and letters, or decode a Base62 string. The result contains no symbols at all, so it is safe in URLs, file names and IDs.

Live demo · real result from this tool
Direction

Encoded

TvmSBZ6cmQqK

Processed on your device — nothing is uploaded.

How to use the Base62 tool

  1. Set Direction to Encode or Decode.
  2. Type your text, or paste a Base62 string, into Input.
  3. Copy the Encoded or Decoded result. Decoded bytes that are not valid text are shown as hex.

What it does and when to use it

Base62 is popular wherever a value must be made of letters and digits only: short link codes, public IDs in URLs, file names, and tokens that must survive double-click selection or systems that strip symbols. Unlike Base64 it needs no +, /, -, _ or =, so there is nothing to escape.

Use this tool to encode a short string into an alphanumeric code, to decode such a code during debugging, or to check an implementation that uses the same alphabet order.

If you need to avoid look-alike characters such as 0 and O, Base58 is the better choice. For a standardised, widely supported URL-safe format, use Base64URL. For a case-insensitive alphabet, see Base32.

How it works

Base62 cannot split bytes into fixed bit groups, because 62 is not a power of two. So it uses number conversion:

  1. Your text becomes UTF-8 bytes, read as one large number, most significant byte first.
  2. The number is divided by 62 repeatedly; each remainder picks a character from 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.
  3. The characters are written most significant first, and leading zero bytes are added back as 0.

Decoding multiplies back up, character by character. The work happens in your browser and is limited to 20,000 bytes, because this kind of conversion slows down sharply on long input.

Worked examples

Hello      →  5TP3P3v
5TP3P3v    →  Hello                                  (Decode)
Hi!        →  JuWP
abc-123    →  “-” at position 4 is not a Base62 character.   (Decode)

“Hi!” is the bytes 0x48 0x69 0x21, which is the number 4,745,505. In base 62 that is J (19), u (56), W (32), P (25): 19 × 62³ + 56 × 62² + 32 × 62 + 25 = 4,745,505. The last line shows that a hyphen is not part of the alphabet.

Limits and tips

  • Changing one byte of the input can change many characters of the output, because the whole input is one number.
  • Do not mix Base62 values from systems with different alphabet orders.
  • For long text, Base64URL is faster and more widely understood.

Frequently asked questions

Why does another Base62 tool give a different result?
Base62 has no single official standard. This tool uses the order 0–9, then A–Z, then a–z, and treats your text's UTF-8 bytes as one big number. Some libraries put lower case before upper case, and many URL shorteners encode a database number rather than text bytes. Both sides must use the same rules.
Is Base62 case-sensitive?
Yes. A and a are different digits, worth 10 and 36. Changing the case of any character changes the decoded result, so never upper-case or lower-case a Base62 value.
How long will the output be?
About 1.34 characters per byte of input, because each Base62 character carries about 5.95 bits. "Hello" is 5 bytes and gives 7 characters.
What happens to leading zero bytes?
Each zero byte at the start of the input is written as a 0 character, and the decoder turns each leading 0 back into a zero byte. Without this rule, those bytes would be lost.
Is Base62 a safe way to hide an ID?
No. It looks random but anyone can decode it. If IDs must not be guessable, generate random IDs instead of encoding sequential ones.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close