Generate Nano IDs: short, URL-safe, cryptographically random identifiers. Pick an alphabet and length, create up to 10,000 IDs at once, and use the collision calculator to see how long it would take before two IDs clash.
Last updated:
Generate
Collision probability
Based on the alphabet and length chosen in the generator.
Advertisement
Advertisement
How to use the Nano ID Generator
Choose an alphabet: the default URL-safe set (A-Z, a-z, 0-9, _ and -) or a preset, or type your own characters.
Set the length (21 is the nanoid default) and how many IDs you need.
Click Generate. IDs appear instantly and are checked for duplicates within the batch.
Check the collision risk: enter how many IDs you create per hour to see how long until a 1% chance of a collision.
Copy or download the list as plain text, comma-separated or a JSON array.
How Nano IDs are generated
A Nano ID is built one character at a time from cryptographically secure random bytes. To keep every character equally likely, the generator does not use byte % alphabetLength (which favors the first characters whenever 256 is not a multiple of the alphabet size). Instead it:
Computes a bitmask: the smallest value of the form 2k - 1 that covers the alphabet (63 for a 64-character alphabet, 63 for 36 characters, 15 for 16).
Takes a batch of random bytes and ANDs each one with the mask.
Uses the result as an index if it falls inside the alphabet, and throws it away if it does not (rejection sampling).
This is the same approach as the open-source nanoid library's customAlphabet, so IDs made here have identical statistical properties.
Entropy by alphabet and length
Each character adds log2(alphabet size) bits. Aim for at least about 100 bits for IDs that must be globally unique; fewer bits are fine for short-lived or low-volume IDs such as invitation codes.
Alphabet
Size
Bits per char
Length for ~126 bits
Bits at length 10
URL-safe (default)
64
6.00
21
60
Alphanumeric
62
5.95
22
59.5
No look-alikes
49
5.61
23
56.1
Lowercase + numbers
36
5.17
25
51.7
Hexadecimal
16
4.00
32
40
Numbers only
10
3.32
38
33.2
The collision formula
The chance that at least two of n random IDs are equal, out of N = alphabet sizelength possible values, is approximately p ≈ 1 - e-n(n-1)/(2N) (the birthday problem). Solving for n gives the number of IDs at which the risk reaches p: n ≈ √(2N · ln(1/(1-p))). For the default 21-character URL-safe ID, N = 6421 = 2126, so a 1% risk takes about 1.3 × 1018 IDs.
Frequently asked questions
What is a Nano ID?
Nano ID is a popular open-source format for random unique identifiers. By default it uses 21 characters from a 64-symbol URL-safe alphabet (A-Z, a-z, 0-9, underscore and hyphen), giving 126 random bits, comparable to the 122 random bits of a UUID v4 in a shorter string.
How likely is a Nano ID collision?
With the default alphabet and length you would need to generate about 1,000 IDs per hour for roughly 149 billion years (on the order of 10^18 IDs) to reach a 1% chance of a single collision. The calculator on this page uses the birthday approximation p = 1 - e^(-n(n-1)/2N), where N is alphabet size raised to the ID length.
Is it safe to use a custom alphabet?
Yes, as long as you keep enough entropy. Each character carries log2(alphabet size) bits, so a smaller alphabet needs a longer ID. The generator uses a bitmask with rejection sampling, so every character is equally likely for any alphabet size, without the modulo bias of naive random % length code.
Nano ID vs UUID: which should I use?
Use UUID when a database column, API or standard requires that format. Use Nano ID when you want shorter, URL-friendly IDs for links, file names or public identifiers. Neither embeds a timestamp, so neither sorts by creation time; use ULID or UUID v7 for that.
Are these IDs generated securely?
Yes. Randomness comes from crypto.getRandomValues, the browser's cryptographically secure generator, the same source the nanoid library uses in browsers. Nothing is sent to a server.
Can Nano IDs start with a hyphen or underscore?
With the default alphabet, yes. If an ID will be used as a command-line argument, CSS selector or HTML id, choose the alphanumeric preset or add a letter prefix.
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.