ZapKit

Nano ID generator

Make compact random IDs for URLs, database keys, invite codes and file names, and see how many you can create before a clash becomes likely.

What is a Nano ID?

A Nano ID is a short random identifier, by default 21 characters drawn from letters, digits, underscore and hyphen. It's a popular alternative to UUIDs for public URLs, database keys and tokens, because it's compact and needs no escaping in URLs or file names.

Choose a preset alphabet or type your own, set the length, number of IDs and an optional prefix, and generate. Alongside the IDs you'll see the alphabet size, the bits of randomness, how many IDs give a 1% chance of a duplicate, and how long that takes at 1,000 new IDs an hour.

How to use the Nano ID generator

  1. 1.Choose an alphabet and length

    21 URL-safe characters is the standard.

  2. 2.Add a prefix if you like

    Like usr_ or inv_ to show what an ID is for.

  3. 3.Generate and copy

    Up to 1,000 IDs, downloadable as text.

Example: the default settings

21 characters from the 64-character URL-safe alphabet:

Randomness
126 bits
IDs for a 1% clash chance
about 1,308 quadrillion
At 1,000 IDs an hour
about 149 billion years

n ≈ √(2 · ln(1/0.99)) × 2^(bits ÷ 2)

For almost any app, a clash is never going to happen in practice.

Random enough, and unbiased

IDs come from your browser's cryptographic random generator. Each random byte is masked to the nearest power of two and values outside the alphabet are thrown away, so every character is equally likely; simply using the remainder would favour some characters.

Collision odds use the birthday bound: the number of IDs at which there's a 1% chance any two match. The default 21 URL-safe characters carry 126 bits, slightly more than a UUID v4, in 21 characters instead of 36.

Frequently asked questions

Nano ID or UUID?

Nano IDs are shorter and URL-safe; UUIDs are a standard many databases understand natively.

Is a shorter length safe?

It depends on volume. The calculator shows when clashes become likely for your settings.

Why avoid look-alike characters?

For codes people read or type, like invite codes, so 0 and O can't be confused.

Are generated IDs stored?

No. They exist only on this page.

More Developer tools