Hash Collision Probability Calculator (Birthday Bound)
Enter how many IDs you generate and how many random bits they have to see the collision risk.
Your numbers
Your results
Hash Collision Probability Calculator (Birthday Bound) by TheCalcTools
How the Hash Collision Probability Calculator (Birthday Bound) works
This is the birthday problem: with N possible values, collisions become likely after about √N items, far sooner than N.
The chance of at least one collision among n random values is about 1 − e^(−n(n−1)/(2N)). For very small probabilities it is about n²/(2N).
The formula
Worked example
Using the default values shown in the calculator:
| Number of IDs or hashes | 1e+09 |
|---|---|
| Random bits per ID | 122 |
- 10⁹ UUIDs give a collision probability of about 9.404e-20.
- A 50% chance needs 2710000000000000000 UUIDs.
Result:
| Probability of at least one collision | 9.404e-20 |
|---|---|
| IDs for a 50% chance of a collision | 2710000000000000000 |
| IDs for a one-in-a-billion chance | 103000000000000 |
Frequently asked questions
Will UUID v4 ever collide?
Practically no: you would need about 2.7 × 10¹⁸ UUIDs for a 50% chance.
How long should short codes be?
Choose enough bits that the expected number of IDs you will ever create gives a negligible probability.
Sources and further reading
Related calculators
More in AI & Computing · All calculators
This calculator gives estimates for information only. Check important results independently before you rely on them. See our disclaimer.
