Skip to content
shellhacks.dev

Nano ID Generator

Generate short random IDs with the URL-safe alphabet, alphanumerics, no look-alikes, hex or your own characters, and see their entropy and collision odds.

Free · No sign-up · Your inputs stay in your browser

Input

Generate Nano IDs

Output

Press Generate

Entropy

126 bits

About 1.3e+18 IDs before a 1% chance of any collision.

Random IDs from crypto.getRandomValues with rejection sampling, the method the nanoid package uses. The default, 21 characters of a 64-symbol alphabet, carries 126 bits: about the same as a UUID v4 in fewer characters.

Runs in this browser. Nothing you paste is sent to a server.

Short IDs, quantified

The nanoid default of 21 characters from a 64-symbol alphabet gives 126 bits, about the same as a UUID v4 in 15 fewer characters. Shorter IDs are fine for share links or order numbers as long as the collision odds fit the volume; the birthday bound shown here is the number to compare with how many you will ever create.

Why rejection sampling

randomByte % alphabet.length favours the first characters whenever 256 is not a multiple of the alphabet size. Throwing away bytes above the largest multiple keeps every character equally likely, which is what nanoid does too.

Share

Frequently asked questions

How long should a Nano ID be?
21 characters for IDs that must never collide. For human-facing codes, pick the shortest length whose collision estimate is comfortably above the number you will generate.
Can I use Nano IDs as database primary keys?
Yes, but random IDs insert at random places in a B-tree index. For large tables, time-ordered IDs such as ULID or UUID v7 index better.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Go deeper

Suggested reading

Keep planning

Similar tools