How to use the Nano ID generator
- Choose an Alphabet: URL-safe (64 characters, the Nano ID default), Alphanumeric (62), Lowercase + digits (36), No look-alikes (49), Hex (16), Digits only, or Custom….
- For Custom, type your characters into Custom alphabet. Repeated characters are counted once.
- Set the Length (2 to 256; 21 by default) and How many IDs (up to 1,000).
- Press Generate, then copy the list. The stats show Entropy per ID and IDs for a 1% collision chance.
What it does and when to use it
Nano IDs are short random strings used as database keys, public record IDs, file names and short-link slugs. They are shorter than a UUID for the same safety, because they use more symbols per character. The URL-safe alphabet needs no escaping in paths or query strings.
The useful part of this page is the second number. Teams often shorten IDs to look tidy without checking the risk. The tool does the sum for you, so you can see how far a shorter ID really goes. For standard 36-character IDs, use the UUID generator. For IDs that sort by creation time, see the ULID generator. For free-form random text, try the random string generator.
How it works
Each character is picked with crypto.getRandomValues and rejection sampling, so every symbol in the alphabet is equally likely.
- Entropy = length × log2(alphabet size). Each URL-safe character carries 6 bits, so 21 characters give 126 bits.
- Collision estimate. With N = alphabet size ^ length possible IDs, the number you can make before a 1% chance that any two match is about √(2 × N × ln(1 / 0.99)). This is the birthday-problem approximation.
Worked examples
- Default Nano ID. URL-safe alphabet, length 21:
Entropy per ID: 126 bits, and the 1% point is about 1.3 × 10^18 IDs. - Short lowercase slug. Lowercase + digits, length 12, gives 62 bits and
IDs for a 1% collision chance: 308,617,316. That is plenty for a blog, but a busy event log could pass it. - Six digits. Digits only, length 6, gives 19.9 bits and a 1% risk after just
142IDs. Short numeric codes need a uniqueness check in your database. - Bad custom alphabet. “aaaa” has only one distinct character, so the tool replies “The alphabet needs at least two different characters.”
Limits and tips
- The tool does not check for duplicates inside a batch or against your data. Add a unique index in the database as a final guard.
- A 1% chance across the whole lifetime of a system is already high for most teams; aim for numbers far below it.
- Custom alphabets with spaces or quotes may need escaping in your code.
Frequently asked questions
Are these the same as the nanoid npm package?
How short can I safely go?
What does the "No look-alikes" alphabet remove?
Can I use a Nano ID as a secret token?
How do we know nothing is uploaded? Test it yourself on the privacy proof page.