Nano ID Generator
Generate URL-safe Nano IDs with any length and alphabet, and see the exact entropy and collision odds.
Entropy & collision odds
How it works
Nano ID is a compact, URL-safe random identifier. This page implements the reference
algorithm from the nanoid library (ai/nanoid, MIT): random bytes come from
crypto.getRandomValues(), each byte is masked down to the smallest bit width
that covers the alphabet, and any value that lands past the end of the alphabet is thrown
away and re-drawn. That rejection step is what keeps every character exactly equally
likely, where a plain byte % alphabet.length would quietly favour the first
few characters. The default is 21 characters from the 64-symbol URL-friendly alphabet
A-Za-z0-9_-, which packs 126 bits of randomness into 21 characters where a
UUID v4 spends 36 characters on 122 bits.
The entropy line is exact: length x log2(alphabet size). The collision line is the standard birthday bound, n = sqrt(2 x alphabet^length x ln(1/0.99)), the number of IDs you would have to mint before there is a 1% chance that any two of them match; dividing by your generation rate turns that into a wall-clock time. Shorten the ID or shrink the alphabet and watch that number collapse, which is a quick way to see that a 10-digit numeric ID is not safe as a primary key. Everything happens in your browser: nothing is uploaded, nothing is logged, and the page keeps working offline once loaded, so the IDs really are yours.
Frequently asked questions
What is a Nano ID?
A Nano ID is a compact random string identifier popularised by the nanoid library. The default is 21 characters drawn from a 64-symbol URL-friendly alphabet (A-Za-z0-9 plus underscore and hyphen), which carries 126 bits of randomness. That is more entropy than a UUID v4's 122 bits in 21 characters instead of 36, and every character is safe in a URL, a filename or an HTML id without escaping.
How long should a Nano ID be?
Long enough that a collision is not worth thinking about. With the default 64-character alphabet, 21 characters give 126 bits: at 1,000 IDs per hour you would need roughly 149 billion years before there is a 1% chance any two match. Shortening to 10 digits drops you to 33 bits, which collides within a day at the same rate. This page prints both numbers as you change the length, so you can pick a size with the odds in front of you.
Are these Nano IDs generated securely in my browser?
Yes. The bytes come from crypto.getRandomValues(), the browser's cryptographically secure random source, and are mapped to your alphabet using nanoid's own rejection-sampling mask, so no character is more likely than another. Nothing is sent to a server, nothing is logged, and the page keeps working offline once loaded, which matters when the IDs will become production primary keys or share tokens.