Generate short, random, URL-safe IDs like Nanoid. Set the length and alphabet, generate up to 1,000 at once, and see exactly how collision-resistant they are — with the code to produce the same IDs in your app.
| Length | Bits | IDs for 1% collision |
|---|---|---|
| 8 | 48 | ≈ 2.4 million |
| 12 | 72 | ≈ 9.7 billion |
| 16 | 96 | ≈ 4 × 10¹³ |
| 21 | 126 | ≈ 1.3 × 10¹⁸ |
A tiny library for random, URL-friendly unique IDs — a shorter alternative to UUIDs.
Yes — 126 bits versus UUID v4's 122.
Check the collision figure: it should be far above the number of IDs you'll ever create.
They use a cryptographically secure generator with no bias.
Yes, any characters.
IDs are drawn from crypto.getRandomValues with Nanoid's own technique. Each random byte is masked to the smallest power of two that covers the alphabet, and values outside it are discarded, so every character is equally likely with no modulo bias. The default is 21 characters from the 64-symbol URL-safe alphabet (A–Z a–z 0–9 _ -), giving 126 bits of entropy. Presets cover alphanumeric, lowercase-plus-digits and a no-look-alikes set, or you can use any custom alphabet. Entropy is length × log₂(alphabet size). The number of IDs giving a 1% chance of any collision uses the birthday bound √(2·N·ln(1/0.99)), where N = alphabetˡᵉⁿᵍᵗʰ. The matching nanoid or customAlphabet snippet is shown.