About Nano ID Generator
Generate compact random identifiers in the style of Nano ID: 21 characters from a 64-character URL-safe alphabet by default, which carries about as much randomness as a UUID in far fewer characters. Change the length, pick another alphabet, or type your own.
Under a single ID you see what your choices mean: the bits of randomness, how many IDs you could make before a repeat reaches a 1% chance, and the odds of a repeat among a million or a billion.
How it works
- Each character is picked with crypto.getRandomValues, the browser’s cryptographic generator. Draws that would favour some characters are thrown away and redrawn, so every character is equally likely.
- The randomness of one ID is its length times log₂ of the alphabet size: 21 characters from 64 give 126 bits.
- Repeat odds come from the birthday problem. Small ID spaces are counted exactly; large ones use the standard estimate, which is accurate to far more digits than shown.
Questions
Are these the same as IDs from the nanoid package?
They follow the same idea and the same default alphabet and length, and draw from the same kind of secure random source. Any ID shown here is a valid Nano ID, but this tool does not run that package.
How long should my IDs be?
Enough that the 1% figure is far beyond the number of IDs you will ever create. For most databases and links, 21 URL-safe characters is generous; 10 to 12 can be fine for a few thousand records.
Can I use emoji or accented letters in a custom alphabet?
Yes. Each character you type counts once, whatever its length in bytes. A character may appear only once, since a repeat would make it come up more often than the rest.
Why do the collision odds disappear when I generate several IDs?
They are shown under a single ID. Set the count back to 1 to see them; they depend only on the length and alphabet, not on how many you generate at once.
Everything you enter here is processed in this browser tab. Nothing is uploaded, logged or shared. How privacy works here.