About this tool
Nano ID is a tiny, popular format for unique IDs: 21 URL-safe characters such as V1StGXR8_Z5jdHi6B-myT, with about the same collision resistance as a UUID v4 in 15 fewer characters. It’s ideal for short links, public record IDs, file names and anything that appears in a URL. This generator makes Nano IDs with any length and alphabet and tells you how many you could create before a collision becomes likely.
How to use it
- Keep the default 21 characters and alphabet for general-purpose IDs.
- Shorten the length or pick another alphabet for friendlier IDs: No look-alikes removes characters such as 1, l, I, 0 and O that people confuse.
- Check the line under the button: it shows the bits of randomness and roughly how many IDs give a 1% chance of any duplicate.
Choosing a length
Collisions follow the birthday problem: the chance of any two IDs matching grows with the square of how many you create. With the default 64-character alphabet, each character adds 6 bits:
- 21 characters (126 bits): you could create a billion IDs every second for about 40 years before reaching a 1% chance of a single collision.
- 12 characters (72 bits): about 10 billion IDs for a 1% chance; fine for most apps’ public IDs.
- 8 characters (48 bits): about 2.4 million IDs for a 1% chance. Check for duplicates when you insert.
// npm install nanoid
import { nanoid, customAlphabet } from 'nanoid';
nanoid(); // 21 chars, e.g. "V1StGXR8_Z5jdHi6B-myT"
nanoid(10); // shorter
const orderId = customAlphabet('0123456789ABCDEFGHJKMNPQRSTVWXYZ', 12);
orderId(); // "4K7M2QXW9RZB"# pip install nanoid
from nanoid import generate
generate() # 21 chars, URL-safe
generate('0123456789abcdef', 16) # custom alphabet and sizeFAQ
What is a Nano ID?
A compact unique ID format, by default 21 characters from a 64-character URL-safe alphabet (A–Z, a–z, 0–9, _ and -), giving 126 bits of randomness.
Nano ID vs UUID: which should I use?
Both are unique enough for practical purposes. Nano ID is shorter and URL-friendly; UUID is a standard with native database types. Use UUID v7 or ULID if you need IDs that sort by time.
How short can a Nano ID be?
As short as you like, but collisions become likely sooner. Use the probability shown under the button to choose a safe length for how many IDs you’ll create.
Can I use my own characters?
Yes. Choose “Custom” and type any alphabet; duplicate characters are removed automatically.