Developer ToolsA little help for every day

Search by name or task, such as JSON or percentage.

Developer Tools

NanoID Generator

Generate up to 1,000 Nano IDs at once from a cryptographic random source. Set length, prefix and alphabet, and see the bits of randomness and collision odds.

View all tools
ResultUpdates as you type

The result appears here as soon as the page has loaded.

How to use NanoID Generator

Set the length, how many IDs you need and the alphabet, and add an optional prefix such as user_. A fresh batch is generated whenever you change a setting, with an estimate of how many IDs it would take to risk a duplicate.

  1. Set length and countThe default is 21 characters, as in the nanoid library; choose 1 to 256 characters and up to 1,000 IDs.
  2. Pick an alphabetUse URL-safe (64), letters and digits, lower case, no look-alikes, hex, digits only, or your own characters.
  3. Add a prefix and copyAdd a prefix such as ord_ for readable IDs, then copy the list, which has one ID per line.

Length, alphabet and collision risk

The default URL-safe alphabet has 64 characters (A–Z, a–z, 0–9, _ and -), so a 21-character ID carries about 126 bits of randomness and you would need roughly 1.3 × 10^18 IDs for a 1% chance of a duplicate. Smaller alphabets need longer IDs: 10 digits give only about 33 bits, and a duplicate becomes 1% likely after roughly 14,178 IDs. The estimate updates with every change, and anything under 64 bits is flagged as unsuitable for public unique IDs. The no-look-alikes set drops characters such as 0, O, 1, l and I for IDs that people have to read or type.

Why there is no modulo bias

Mapping a random number onto an alphabet with the remainder operator makes some characters slightly more likely whenever the alphabet size does not divide the random range evenly. This generator uses rejection sampling instead: random values that fall outside the largest even multiple are thrown away and drawn again, so every character is equally likely with any alphabet size, including custom ones. Random numbers come from the browser's crypto.getRandomValues, and duplicate characters in a custom alphabet are removed before generating.

Accuracy and data handling

Validate the result with your project's own tests and runtime rules before using it in production. The calculation runs in your current browser; the tool code does not send the input to a processing API.

Often Used Together

Next step

FAQ

What is the difference between Nano ID and UUID?

A version 4 UUID is 36 characters with 122 random bits. A default Nano ID is 21 URL-safe characters with about 126 bits, so it is shorter with similar collision resistance.

Can I generate numeric-only IDs?

Yes, choose Digits only. Each digit adds only about 3.3 bits, so make them longer: 10 digits give about 33 bits, fine for internal references but not for unguessable tokens.

Will the IDs ever repeat?

In theory yes, but at the default settings the chance is negligible. The estimate under the list shows how many IDs you could create before a duplicate reaches a 1% chance.

More Developer Tools

Related tools