AI & Computing

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

UUID v4 has 122 random bits; an 8-character base-62 code has about 47.6

Your results

Probability of at least one collision
Probability of at least one collision
—
IDs for a 50% chance of a collision
—
IDs for a one-in-a-billion chance
—

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

P ≈ 1 − exp(−n(n − 1) ÷ (2 × 2^bits))

Worked example

Using the default values shown in the calculator:

Number of IDs or hashes1e+09
Random bits per ID122
  1. 10⁹ UUIDs give a collision probability of about 9.404e-20.
  2. A 50% chance needs 2710000000000000000 UUIDs.

Result:

Probability of at least one collision9.404e-20
IDs for a 50% chance of a collision2710000000000000000
IDs for a one-in-a-billion chance103000000000000

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

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.