Nano ID Generator

Short random IDs that are safe in URLs and file names. The page shows how strong your settings are, so you can pick a length from how many IDs you will make. Everything is made on this device.

How it works

A Nano ID is a string of characters drawn at random, one at a time, from an alphabet. The standard alphabet has 64 characters: A to Z, a to z, 0 to 9, - and _. All of them are safe in a URL, a file name or an HTML id, so the ID never needs escaping.

Each character from a 64-character alphabet carries 6 bits of randomness, so the default length of 21 gives 126 bits. That is about the same as a random UUID, which has 122, in 21 characters instead of 36.

The random bytes come from crypto.getRandomValues. When the alphabet size does not divide 256 evenly, bytes that would make some characters more likely than others are thrown away and drawn again, so every character in the alphabet has exactly the same chance.

How to use it

  1. 1 Pick an Alphabet: URL-safe (the standard one), Numbers, Lowercase and numbers, No lookalikes, or Custom, where you type the Characters to use.
  2. 2 Set the Length. 21 is the standard.
  3. 3 Set How many IDs to make.
  4. 4 Check the strength line: the bits of entropy and about how many IDs you can make before there is a 1% chance that two match.
  5. 5 Copy the IDs, download them, or press Regenerate for a fresh set.

Good to know

  • If you shorten the ID, check the collision line. Every character you remove divides the safe number of IDs by about 8 with the standard alphabet.
  • A smaller alphabet needs a longer ID for the same strength. 21 digits give only about 70 bits, against 126 for 21 URL-safe characters.
  • No lookalikes leaves out characters such as I, l, 1, O and 0, which helps when people have to read an ID aloud or type it from paper.
  • The collision estimate assumes the IDs are random and independent. It says nothing about an ID being secret once you have shared it.

Browser support

  • Chrome 94 and later
  • Firefox 93 and later
  • Safari 16.4 and later
  • Edge 94 and later

These are the oldest versions with everything the tool uses. They are worked out from the tool itself, so they change when it does.

Version numbers checked on 2026-09-04.

Why 21 characters, and why the alphabet has exactly 64

The standard Nano ID is 21 characters from a 64-character alphabet. Both numbers are chosen on purpose, and you can check the arithmetic behind them in a few minutes. It also tells you what happens when you change either one.

Start with the alphabet. A computer’s random source gives bytes, and a byte has 256 possible values. To turn a byte into a character, you divide it by the alphabet size and keep the remainder. With 64 characters this is perfect: 256 is exactly 4 × 64, so byte values 0, 64, 128 and 192 all map to the first character, and every character gets exactly four byte values. Each one has the same 1 in 64 chance, and no byte is ever wasted. A 64-character alphabet is also the largest you can build from letters, digits and the two symbols, - and _, that need no escaping in a URL.

Now try 62 characters, letters and digits only, which many people prefer because - and _ look odd in an ID. 256 divided by 62 is 4 with 8 left over. If you simply used the remainder, the byte values 248 to 255 would land on the first 8 characters, giving each of them 5 chances in 256 while the rest get 4. Those 8 characters would turn up 25% more often than the others, which quietly makes the IDs easier to guess. This generator avoids that by throwing away any byte of 248 or more and drawing again. That wastes 8 bytes in every 256, about 3%, and keeps every character exactly equally likely.

Next, the length. Each character from 64 choices carries log2(64) = 6 bits, so 21 characters carry 126 bits. With 62 characters each one carries about 5.95 bits, and 21 of them give about 125. The question that matters is how many IDs you can make before two match by chance. Because of the birthday effect, the answer is roughly the square root of the number of possible IDs, not the number itself. For 126 bits, the count at which there is a 1% chance of a single collision anywhere in your data is about 1.3 × 10^18. Making 1,000 IDs every second, you would reach it in about 41 million years.

That is why the page shows the collision line instead of asking you to trust a default. If you shorten the ID to 8 characters, you have 48 bits, and the 1% point drops to about 2.4 million IDs, which a busy table can reach. Switch the alphabet to digits only and keep 21 characters, and you have about 70 bits, with the 1% point near 4.5 billion. Pick the length from the most IDs you will ever hold, with a wide margin.

The limits are worth knowing. The estimate assumes a good random source, which crypto.getRandomValues is in every current browser. It does not make an ID a secret: once an ID appears in a URL or a log, anyone who sees it has it. And Nano IDs carry no time or order, so if you need IDs that sort by creation time, a version 7 UUID is the better fit.

Frequently asked questions

Is a Nano ID better than a UUID?

It is shorter for the same strength and safe in URLs without escaping. A UUID has a fixed, widely understood format that databases and libraries know. Neither is more unique than the other at the default settings: 126 bits against 122.

How short can I make the ID?

That depends on how many you will make. The page shows about how many IDs you can create before there is a 1% chance of any two matching. Keep that number well above the most you will ever store.

Why do some alphabets need bytes to be thrown away?

A random byte has 256 values. With 64 characters, each one gets exactly 4 of those values. With 62, 256 does not divide evenly, so the leftover 8 byte values would give 8 characters an extra chance. Those bytes are discarded and redrawn instead.

Are the IDs made on a server?

No. They are made in your browser from crypto.getRandomValues, and nothing is sent anywhere.

Can I use a custom alphabet with emoji or accented letters?

Yes. The Characters box counts each character once, emoji included. Remember that such IDs will need escaping in a URL.

Related tools

Your files are processed on your device and are not uploaded. You can verify this in your browser’s developer tools under the Network tab.