Hash Collision Probability Calculator
Calculate the probability of a hash or ID collision (birthday bound) for any hash size in bits — CRC-32, 64-bit IDs, UUID v4, MD5, SHA-256 — and how many items give a 50% or one-in-a-billion chance.
How it works
p ≈ 1 − e^(−n(n − 1) ÷ (2 × 2^b)) · expected colliding pairs = n(n − 1) ÷ (2 × 2^b) · items for 50% ≈ √(2 ln 2 × 2^b) ≈ 1.1774 × 2^(b/2) · items for probability p ≈ √(2 × 2^b × p) (small p)
This is the birthday problem applied to hashes: with n items and 2^b equally likely values there are n(n − 1)/2 pairs, each colliding with probability 2^−b, so collisions become likely after only about 2^(b/2) items — the birthday bound. A 32-bit CRC hits 50% at about 77,000 items, a 64-bit ID at about 5 billion, while 122-bit random UUIDs need around 2.7 × 10^18. The formula assumes a uniformly random hash; it says nothing about deliberate attacks on a broken hash such as MD5 or SHA-1.
Worked example
Hashing 1,000,000,000 items into 64 bits: n(n − 1)/2 ÷ 2^64 = 0.0271 expected colliding pairs, so the collision probability is 1 − e^−0.0271 = 2.67% (one chance in about 37.4). A 50% chance needs 5.06 × 10^9 items and a one-in-a-billion chance is reached at 192,077 items.
Sources: Wikipedia — Birthday attack (probability table) · RFC 9562 — Universally Unique IDentifiers (UUIDs)
Frequently asked questions
How likely is a UUID collision?
A version 4 UUID has 122 random bits. Generating a billion UUIDs gives a collision probability of about 10^−19; you would need around 2.7 × 10^18 UUIDs for a 50% chance.
What is the birthday bound?
It is the rule of thumb that collisions in a b-bit hash become likely after about 2^(b/2) values, the square root of the number of possible outputs — the same effect that makes two people in a room of 23 share a birthday half the time.
Is a 32-bit hash enough for unique IDs?
Rarely. With 32 bits there is already a 1% chance of a collision at about 9,300 items and 50% at about 77,000. Use 64 bits or more for identifiers, and 128 bits for anything global.
Does this apply to SHA-256 security?
It gives the generic collision resistance of 2^128 operations for SHA-256. Hashes with known cryptographic weaknesses (MD5, SHA-1) can be collided far faster on purpose, so the random-collision figure does not measure their security.
Related calculators
This calculator is for educational purposes. Double-check important results before acting on them.