NanoID Generator
Generate short, URL-safe random IDs in the NanoID style. Choose the length, how many you need and the exact set of characters to draw from.
Use the tool
Why this tool exists
Sometimes a UUID is more than you need: it is long, full of hyphens and awkward in URLs. NanoID-style identifiers are compact, and you control the alphabet. That helps with short links, invite codes, order references or test data where you want digits only, lowercase only or no look-alike characters.
This tool builds IDs from the browser's secure random source and avoids the modulo bias that makes some characters more likely than others. The default length of 21 with the 64-character URL-safe alphabet gives roughly the same collision resistance as a v4 UUID. Shorten the length or shrink the alphabet and that margin drops, so pick values with the number of IDs you expect in mind.
How to use it
- Set the length of each ID, from 1 to 256.
- Set how many IDs to generate, up to 1000.
- Edit the alphabet if you want only certain characters, such as digits or lowercase letters.
- Copy the list of IDs.
Frequently asked questions
What is the default alphabet?
The standard URL-safe set of 64 characters: underscore, hyphen, digits, and lowercase and uppercase letters. With a length of 21, collisions are about as unlikely as with a random UUID.
How short can I safely go?
It depends on how many IDs you will create. Fewer characters or a smaller alphabet means a higher chance of two matching. For anything stored long term, check uniqueness in your database rather than relying on chance.
Does it remove duplicate characters from my alphabet?
Yes. Repeated characters are collapsed so every symbol has equal probability. The alphabet must contain between 2 and 256 distinct characters, otherwise you get an error.
Is this the official nanoid library?
No. It is a small re-implementation of the same approach, using the browser's secure random bytes with rejection sampling. The output format matches, but it is not a copy of that package.