Hash collision probability calculator

Enter the size of the hash or random ID in bits and how many items you will store. The calculator applies the birthday bound to give the probability of at least one collision, and tells you how many items it takes to reach a 50 %, 1 % or one-in-a-million chance.

32 for CRC-32, 64 for a 64-bit hash, 122 for a random UUID v4, 128 for MD5, 256 for SHA-256.
Exponents are fine: 1e9 is a billion.
Probability of at least one collision2.674 %
That is about 1 in
37.4
Expected colliding pairs
0.0271
Possible values 2ᵇ
1.845e+19
Items for a 50 % chance
5,056,937,541
Items for a 1 % chance
608,926,882
Items for a one-in-a-million chance
6,074,003

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Enter the size of the hash or random identifier in bits.
  2. Enter the number of items: files, records, IDs. Large numbers can be written as 1e9 or 5e12.
  3. Read the collision probability, the expected number of colliding pairs and the item counts that reach 50 %, 1 % and one in a million.

Formula

With N = 2ᵇ possible values and n items:

  • P(collision) = 1 − exp(−n(n − 1) ÷ 2N), computed so that tiny probabilities keep their digits.
  • Expected pairs = n(n − 1) ÷ 2N; when it is small, it is almost equal to the probability.
  • Items for probability p: n = ½ + √(¼ + 2N·ln(1 ÷ (1 − p))).

Worked example

A 64-bit hash for 1,000,000,000 (10⁹) items:

  • N = 2⁶⁴ = 1.845e+19 possible values.
  • n(n − 1) ÷ 2N ≈ 10¹⁸ ÷ 3.69 × 10¹⁹ = 0.0271 expected pairs.
  • Probability = 1 − e^(−0.0271) = 2.674 %, about 1 in 37.4.
  • A 50 % chance is reached at 5,056,937,541 items; 1 % at 608,926,882; one in a million at 6,074,003.

Tips

  • Doubling the items quadruples the risk while it is small, because it grows with n².
  • Two more bits double the items you can store for the same risk: every extra bit multiplies N by 2 and the safe n by √2.
  • Truncated hashes (the first 8 hex characters of a SHA-256, for example) have only 4 bits per hex character: 8 characters are 32 bits, and collisions appear after tens of thousands of items.

Frequently asked questions

How is the collision probability calculated?

With N = 2ᵇ equally likely values and n items, the chance that all are different is about exp(−n(n − 1) ÷ 2N), so the chance of at least one collision is 1 − exp(−n(n − 1) ÷ 2N). This is the birthday problem with N days instead of 365.

How many items until a 50 % chance of a collision?

About 1.1774 × √N, which is roughly 2^(b/2). For 32 bits that is about 77,000 items, for 64 bits about 5.1 billion, for 128 bits about 2.2 × 10^19.

Does this apply to UUIDs?

Yes. A random version 4 UUID has 122 random bits, so enter 122. Even a billion UUIDs give a collision probability of about 10⁻¹⁹. Time-based IDs such as UUID v7 have fewer random bits per millisecond, so the risk depends on how many you create at the same moment.

Does it mean the hash is cryptographically secure?

No. The formula assumes outputs behave like random values. A broken hash such as MD5 or SHA-1 can be attacked to produce collisions on purpose, far faster than the birthday bound suggests.

More in Developer

All tools in this category: Developer ·Updated November 7, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.