Nano ID generator
What is a Nanoid Generator?
Nano ID is a tiny, secure, URL-friendly unique ID format. A default Nano ID looks like V1StGXR8_Z5jdHi6B-myT: 21 characters from a 64-symbol alphabet of letters, digits, underscore and hyphen. It is a popular alternative to UUIDs for database keys, short links, file names and API resource IDs because it is shorter and needs no escaping in URLs.
How to use it
- Choose the number of IDs to generate.
- Set the length and, optionally, a custom alphabet.
- Copy the IDs.
How strong are Nano IDs?
Each character from the default 64-symbol alphabet carries 6 bits of randomness, so 21 characters give 126 bits, comparable to a UUID v4 (122 bits). IDs are generated with a cryptographically secure random source, so they are unpredictable.
Choosing a length
Shorter IDs are friendlier but collide sooner. With the default alphabet:
- 21 characters: you would need to generate about a billion IDs per second for many thousands of years to reach a 1% collision chance.
- 10 characters (60 bits): about 1 billion IDs gives roughly a 1 in 2,300 collision chance.
- 8 characters (48 bits): collisions become likely after millions of IDs.
Custom alphabets
- Use
0123456789abcdefghijklmnopqrstuvwxyzfor case-insensitive systems. - Remove look-alike characters such as 0, O, 1, l and I for codes people type by hand.
- A smaller alphabet carries fewer bits per character, so increase the length to compensate.
Nano ID vs. UUID vs. ULID
Use UUID when a standard format is required, ULID or UUID v7 when IDs must sort by creation time, and Nano ID for short, URL-safe random IDs.
Frequently Asked Questions
How long should a Nano ID be?
The default of 21 characters is safe for virtually any application. Use shorter IDs only after checking the collision risk for your volume.
Are Nano IDs secure?
Yes. They are generated with a cryptographically secure random source and cannot be predicted.
Are Nano IDs sortable by time?
No. They are random. Use ULID or UUID v7 if you need time-ordered IDs.
Can I use my own alphabet?
Yes. A smaller alphabet carries fewer bits per character, so increase the length to keep the same collision safety.