Nano ID Generator and Collision Calculator

Create secure, URL-friendly Nano IDs of any length and alphabet, and check how safe that combination is against collisions at your generation rate.

Loading tool…

About the Nano ID Generator

Nano ID is a small random ID format: by default 21 characters from the 64 URL-safe symbols A-Za-z0-9_-. Each character carries 6 bits, so a default ID has 126 bits of entropy, slightly more than the 122 random bits of a UUID v4, in 21 characters instead of 36. It contains no timestamp and no structure, which makes it a good fit for public identifiers, short links and tokens that should reveal nothing.

This page uses the reference algorithm. Random bytes come from crypto.getRandomValues; each byte is masked to the smallest power of two that covers the alphabet, and values beyond the last character are discarded and drawn again. A simple byte % length would make the first characters of the alphabet more likely whenever the length is not a power of two; rejection keeps every character equally probable. Presets cover digits, lower or upper case, alphanumeric, hex and an alphabet without look-alike characters; a custom alphabet may hold 2 to 256 unique characters.

Shorter IDs and smaller alphabets are more convenient but collide sooner. The calculator applies the birthday bound: with b bits per ID, about √(2 · 2b · ln(1/0.99)) IDs give a 1% probability of at least one collision. For the default settings that is about 1.3 × 1018 IDs, or roughly 149 billion years at 1,000 IDs per hour. Enter your own rate to see whether a shorter ID is still safe for your volume.

How to use it

  1. Set the size of the ID and how many to generate.
  2. Pick an alphabet preset or type your own characters.
  3. Enter how many IDs you create per hour or per second to see the collision estimate.
  4. Click Generate, then Copy all or Download.

Frequently asked questions

How long should a Nano ID be?
Long enough that the time to a 1% collision probability is far beyond the life of your system. The default 21 characters is safe for practically any volume; 10–12 characters of the default alphabet are fine for thousands of IDs per day, as the calculator shows.
Is Nano ID better than UUID?
It is shorter for the same randomness and lets you choose the alphabet. UUIDs have a standard format, native database types and, with v7, time ordering. Use UUID when a system expects one, Nano ID when you control both ends and want compact IDs.
What does modulo bias mean?
Mapping a random byte to an alphabet with the remainder operator favours the first characters when 256 is not a multiple of the alphabet size. With 62 characters, the first 8 would appear 25% more often. Nano ID rejects out-of-range values instead, so the distribution stays uniform.
Can I use these IDs as secrets or API keys?
They come from the browser's cryptographic random generator, so with enough entropy (128 bits or more) they are unguessable. Generate secrets on a device you trust and treat them like passwords.

Related tools