ID Collision Probability Calculator
Every system that generates random identifiers — UUIDs, ULIDs, short URL slugs, one-time codes — is quietly relying on the odds that two of them never turn out the same. This tool estimates that risk using the same math behind the classic "birthday paradox": collisions become likely far sooner than intuition suggests.
Why This Matters
If you generate enough random IDs from a fixed-size space, eventually two will match by pure chance. The surprising part is how few you need before the odds stop being negligible. With only 23 people in a room, there's already a 50% chance two share a birthday — out of 365 possible days. The same math applies to database IDs, session tokens, and short codes, just at a much larger scale.
Knowing this lets you pick an ID scheme (and a bit-length) that keeps collision risk acceptably low for the number of IDs your system will actually generate over its lifetime.
The Formula
For n randomly generated IDs drawn from a space of size N (where N = 2^bits), the approximate probability of at least one collision is:
To instead solve for how many IDs n you can generate before reaching a target collision probability p, the formula is rearranged:
A useful reference point is the number of IDs at which collision odds hit exactly 50% — the "birthday bound":
How to Use This Calculator
- Pick an ID type from the preset dropdown — common schemes like UUIDv4, UUIDv7, ULID, an 8-character Base62 short code, or a 6-digit numeric OTP each come with their known amount of random entropy pre-filled.
- Choose "Custom bit length" instead if you're designing your own ID scheme, and enter the number of random bits it uses.
- Enter how many IDs you expect your system to generate in total (over its lifetime, or in a given period you care about).
- Set a target collision probability (as a percentage) — this is the risk threshold you're willing to accept, commonly 1% or 0.01% for critical identifiers.
- Submit to see your actual collision probability at that count, how many IDs you could generate before hitting your target risk, the birthday-bound reference point, and a table showing how the odds climb at common scales.
Worked Example
Say you're generating standard UUIDv4 values (122 bits of randomness, so N = 2^122) and expect to create 1 billion of them over your application's lifetime (n = 1,000,000,000).
Plugging into the formula:
That's roughly a 1-in-10.6-quintillion chance — effectively zero, which is why UUIDv4 is considered collision-safe for almost any realistic workload. Compare that to a 6-digit numeric OTP (N = 10^6, about 19.9 bits): generating just 1,177 of them already crosses the 50% collision mark, which is exactly why OTPs are short-lived and scoped to one user at a time rather than drawn from a shared global pool.
Common ID Schemes and Their Entropy
| Scheme | Approximate random bits |
|---|---|
| UUIDv4 | 122 bits |
| ULID (random portion) | 80 bits |
| UUIDv7 (random portion) | 74 bits |
| 8-character Base62 string | ~47.6 bits |
| 6-digit numeric code (OTP) | ~19.9 bits |
Use the "Custom" option for anything else — nanoid with a different alphabet/length, a numeric range, or an internal ID format — by computing bits = log2(size of your ID space).