Home
/
Apps
/
ID Collision Probability Calculator
ID Collision Probability Calculator

ID Collision Probability Calculator

Estimate the probability of a collision when generating random UUIDs, ULIDs, or short codes, and find how many IDs you can safely generate before risk grows.

Estimate the probability of a collision when generating random UUIDs, ULIDs, or short codes, and find how many IDs you can safely generate before risk grows.

Only used when ID Type above is set to "Custom bit length"

Total over the system's lifetime, or over the period you care about

The risk threshold you're willing to accept, e.g. 1 for 1%

Share this app

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:

P1en(n1)2NP \approx 1 - e^{-\frac{n(n-1)}{2N}}

To instead solve for how many IDs n you can generate before reaching a target collision probability p, the formula is rearranged:

n2Nln(11p)n \approx \sqrt{2N \cdot \ln\left(\frac{1}{1-p}\right)}

A useful reference point is the number of IDs at which collision odds hit exactly 50% — the "birthday bound":

n501.1774Nn_{50} \approx 1.1774 \sqrt{N}

How to Use This Calculator

  1. 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.
  2. Choose "Custom bit length" instead if you're designing your own ID scheme, and enter the number of random bits it uses.
  3. Enter how many IDs you expect your system to generate in total (over its lifetime, or in a given period you care about).
  4. 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.
  5. 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:

P1e(109)22×21229.4×1020P \approx 1 - e^{-\frac{(10^9)^2}{2 \times 2^{122}}} \approx 9.4 \times 10^{-20}

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).