ID collision calculator
Runs 100% in your browser — nothing is uploaded
entropy = L × log₂(A) = 8 × log₂(62) = 47.63 bits · 2.18 × 10¹⁴ possible values
20,000,000 IDs
Chance of at least one collision
60%
1 − e^(−n(n−1)/2N); exact to many digits at this size.
Expected duplicate pairs
0.916
n(n−1)/2N: the average number of colliding pairs.
50% chance at
17.4 million
About 1.18 × √N IDs, the birthday bound.
How many IDs until…
| 1 in a billion chance | 661 |
| 1 in a million chance | 20,897 |
| 1% chance | 2.09 million |
| 50% chance | 17.4 million |
| 99% chance | 44.8 million |
Sample IDs (8 × 62 characters)
Made with crypto.getRandomValues, skipping bytes that would make some characters more likely than others.
Common ID formats
| Format | Random bits | IDs for a 1-in-a-million chance | IDs for a 50% chance | Note |
|---|---|---|---|---|
| 22 random Base62 characters | 131.0 | 73.6 quadrillion | 6.13 × 10¹⁹ | A random ID as long as a short UUID |
| Nano ID (21 × 64 characters) | 126 | 13 quadrillion | 1.09 × 10¹⁹ | Nano ID's default |
| UUID v4 | 122 | 3.26 quadrillion | 2.71 × 10¹⁸ | In any encoding, short or long |
| ULID | 80 | 1.55 billion | 1.29 trillion | IDs made in the same millisecond |
| UUID v7 | 74 | 194 million | 162 billion | IDs made in the same millisecond |
| 11 × Base64 characters | 66 | 12.1 million | 10.1 billion | The length of a video ID on a well-known site |
| 8 × Base62 characters | 47.6 | 20,897 | 17.4 million | A typical URL shortener |
| 8 hex characters | 32 | 93 | 77,163 | A 32-bit number, or the start of a UUID |
| 6 × Base36 characters | 31.0 | 66 | 54,933 | A short code people type in |
For time-based IDs (ULID, UUID v7), only IDs made in the same millisecond can collide, so the counts are per millisecond across all generators. A generator that counts within a millisecond, as RFC 9562 allows, can't collide with itself at all.
The math
Entropy. A random string of length L from an alphabet of A characters can be any of AL values, which is L × log₂(A) bits. Each Base62 character is worth 5.95 bits, each Base64 character 6, each hex digit 4. That only holds if every character is chosen independently and uniformly by a secure random generator: a timestamp, a counter or a biased generator gives fewer bits than the formula says.
Collisions. With N = 2bits possible values, the chance that n IDs are all different is (1 − 1/N)(1 − 2/N)…(1 − (n−1)/N). The calculator multiplies that out (as a sum of logarithms) for up to a million IDs. Beyond that, it uses the standard approximation
P ≈ 1 − e^(−n(n−1) / 2N)
which comes from 1 − x ≈ e−x for small x. It's an approximation, not an exact formula, but for any realistic ID space its error is far too small to show. The surprise of the birthday paradox is the square root: the chance reaches 50% at about 1.18 × √N IDs, not at N/2. With 365 birthdays, 23 people are enough; with 47.6 bits (8 Base62 characters), 17 million IDs are.
What a collision costs. If the ID is a database primary key, a duplicate is usually a failed insert that can simply be retried with a new ID; a unique index catches it. It's worse when IDs are checked nowhere, like file names in object storage or tokens in links, where a duplicate silently overwrites or exposes something. Choose the length for the case you can't detect.
Converting a UUID to a short UUID doesn't change any of this: it's the same number in fewer characters.