All articles
Identifiers

NanoID, Base58, and Short ID Generation

Generate Secret Keys team June 4, 2026 6 min read

A UUID is 36 characters of guaranteed uniqueness — but sometimes that's more than you need. For a public URL like /p/V1StGXR8, a shorter, friendlier identifier reads better and still avoids collisions. That's where NanoID and Base58 come in.

When a UUID is overkill

UUIDs are perfect for database keys and distributed systems. But for share links, invite codes, or public object IDs, their length and hyphens are clunky. Short random IDs give you compact, copy-friendly, URL-safe values while letting you dial collision risk to whatever your scale requires.

NanoID

NanoID is a tiny, modern ID scheme built on a CSPRNG. By default it produces 21-character strings from a 64-symbol URL-safe alphabet (A–Z a–z 0–9 _ -), giving roughly 126 bits of randomness — comparable to a UUID v4 — but it's fully configurable:

  • Custom length: trade size for collision resistance.
  • Custom alphabet: restrict to digits, or to a human-friendly set.
  • Secure by default: it uses a cryptographic RNG, not Math.random().

Base58

Base58 is the alphabet popularized by Bitcoin. It's Base62 (A–Z a–z 0–9) with four confusable characters removed — 0 (zero), O (capital o), I (capital i), and l (lowercase L). The result is an ID a human can read aloud, retype, or transcribe with far less chance of error, which is why it's used for wallet addresses and public keys.

Length vs collision probability

Short IDs are random, so two could theoretically collide. The math (the "birthday problem") is friendlier than intuition suggests. For an alphabet of size A and length L, the space is AL:

  • A 21-character NanoID (~126 bits) is collision-safe even at astronomical volumes.
  • A 10-character NanoID (~60 bits) is fine for millions of IDs.
  • Shorter still (8 chars) suits low-volume, human-typed codes — pair it with a uniqueness check in your database.

Rule of thumb: pick the shortest length whose space dwarfs the number of IDs you'll ever create, then add a few characters of headroom.

One important caveat

Short IDs are identifiers, not secrets. If an ID grants access (a password-reset link, an unguessable download URL), treat it like a token and give it full entropy — see API tokens. Use short IDs for naming things, not for protecting them.

Generate short IDs now

The IDs & Strings tab generates NanoID-style strings, Base58 tokens, URL slugs, and custom-alphabet random strings at any length — in bulk, locally in your browser.

Need a short, friendly ID? Generate NanoID or Base58 values at the length that fits your scale.

Open the ID generator