Random NanoID Generator

Choose an alphabet, a length, and how many IDs you need, add a prefix if you like, and press Generate IDs. You also see how many IDs you can make before a collision becomes likely.

Try a preset

About this NanoID generator

NanoID is a popular way to create unique identifiers for database rows, short links, file names, and API keys. A default NanoID is 21 characters from a 64-character, URL-safe alphabet, giving about 126 bits of randomness, close to a UUID v4 but much shorter and with no dashes. This generator works the same way, picking every character with your browser’s cryptographically secure random generator and without the bias of a simple modulo. You can switch to hexadecimal, digits, letters, an alphabet without look-alike characters, or your own characters, change the length, and add a prefix such as user_. The collision estimate uses the birthday bound, so you can choose the shortest safe length.

How to generate NanoIDs

  1. Pick the alphabet. Keep the default, choose another set such as hex or no look-alikes, or enter your own characters.
  2. Set length and count. Choose the ID length and how many IDs you need, and add an optional prefix.
  3. Press Generate IDs. Copy or download the IDs, check the collision estimate, and copy the matching code for your project.

Frequently asked questions

What is the difference between NanoID and UUID?

Both are random unique IDs. A UUID v4 has 122 random bits in 36 characters with dashes; a default NanoID has 126 bits in 21 URL-safe characters, so it is shorter and fits nicely in URLs.

How short can a NanoID be?

It depends on how many IDs you make. The safety line shows how many IDs you can create before a duplicate becomes a 1% risk; pick a length where that number is far above your needs.

Is NanoID secure enough for tokens?

With the default length, yes: it uses a cryptographically secure random source, so IDs cannot be predicted. Shorter or smaller alphabets are fine for public IDs but weaker as secrets.

Why remove look-alike characters?

Characters such as 0 and O or 1, l, and I are easy to confuse when an ID is read aloud or typed from paper, so codes for people to type are clearer without them.

Can I use these IDs in URLs?

The default, letters, digits, and hex alphabets contain only URL-safe characters. A custom alphabet with symbols such as / or ? would need encoding in URLs.