Developer tools

Nano ID Generator

Nano ID Generator

Generate short, URL-safe Nano IDs with any length and alphabet, and see the collision risk.

About this tool

About Nano ID Generator

Nano ID is a compact alternative to UUIDs: 21 URL-safe characters give about the same uniqueness as a 36-character UUID v4. This generator produces Nano IDs with the same algorithm as the popular JavaScript library: bytes from the browser's cryptographic random generator, mapped to the alphabet with rejection sampling, so no character is more likely than another. Change the ID length from 2 to 64, and pick an alphabet: the default URL-safe set, letters and digits only, lowercase, a no-look-alikes set that drops 0, O, 1, l and I for codes people type by hand, hex, digits only, or your own characters. The collision panel answers the question people actually have: at your rate of IDs per second, hour or day, how long until there is a 1% chance that two IDs clash? It also shows the bits of entropy per ID. Generate up to 200 IDs at once, then copy or download them.

Built and maintained by Abhi JainUpdated

How to Generate Nano IDs

  1. 1

    Set length and alphabet

    Move ID length and choose an Alphabet, or pick Custom alphabet and type your own characters.

  2. 2

    Check the risk

    Enter how many IDs you create per second, hour or day to see the time until a 1% collision chance.

  3. 3

    Copy the IDs

    Set How many, then copy single IDs, Copy all or Download. Click Generate new for more.

Nano ID Generator: questions and answers

How unique is a 21-character Nano ID?

It has 126 bits of entropy (21 × 6 bits). At 1,000 IDs per second you would need about 41 million years to reach a 1% chance of one collision, which is comparable to UUID v4's 122 random bits.

How is the collision probability calculated?

With the birthday bound. For N possible IDs (alphabet size to the power of length), the number of IDs n that gives probability p of a collision is about √(2N · ln(1/(1−p))). Dividing n by your rate gives the time.

Why not just use Math.random()?

Math.random() is not cryptographically secure and can be predicted. Also, mapping random bytes to an alphabet with the modulo operator makes some characters more common. This tool uses crypto.getRandomValues with rejection sampling to avoid both problems.

Which alphabet should I use?

The default URL-safe alphabet works in URLs and file names. Use No look-alikes for codes people read aloud or type, and Lowercase + digits for case-insensitive systems. A smaller alphabet needs a longer ID for the same safety.

Nano ID or UUID?

Nano IDs are shorter and URL-friendly. Choose a UUID when a database type, API or standard requires one, or when you want v7's time ordering.