Hash Collision Probability Calculator (Birthday Problem)
Calculate the probability of at least one hash or ID collision for a given hash size and number of items, using the birthday-paradox formula — plus how many items it takes to reach a 50%, 1%, 0.01% or custom collision risk.
Input
The number of possible distinct values the hash or ID can take (2^bits).
How many random hashes/IDs get generated. Accepts plain numbers or scientific notation like 1e12.
The 50% / 1% / 0.01% thresholds below are always shown too.
Output
Collision Probability Results
| Metric | Value |
|---|---|
| No data yet | |
More ways to use this tool
REST API
curl -X POST https://api.iotools.cloud/v1/tool/hash-collision-probability-calculator \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"hashSize": "256",
"items": "1000000",
"targetProbability": "50"
}'Swap in your own key from your account. The tool's fields are the body — no wrapper.
Ask an AI agent
Use the IOTools `hash-collision-probability-calculator` tool (Hash Collision Probability Calculator (Birthday Problem)) on this input:
YOUR_INPUT_HEREPaste this at any agent connected to the IOTools MCP server, then add your input.
Embed widget
<iframe
src="https://iotools.cloud/embed/hash-collision-probability-calculator/"
width="100%" height="520" frameborder="0" scrolling="no" loading="lazy"
title="Hash Collision Probability Calculator (Birthday Problem) — iotools.cloud"
sandbox="allow-scripts allow-forms allow-same-origin allow-downloads allow-popups allow-popups-to-escape-sandbox"
allow="clipboard-write"
style="width:100%;border:1px solid #e5e7eb;border-radius:12px;overflow:hidden"></iframe>
<script src="https://iotools.cloud/embed.js" async></script>Drop this into your own page — free, no key required, just a link back.
| Cost per API/MCP call | From 5 credits |
|---|---|
| Need more credits? | View pricing |
Also available with
Guides
What it does
This calculator answers the question behind the "birthday paradox": if you generate a lot of random hashes or IDs, how likely is it that two of them turn out to be identical? It uses the standard birthday-paradox approximation
P(collision) ≈ 1 - e^(-n(n-1) / 2H)where n is the number of items you generate and H is the size of the hash or ID space (2^bits — for example 2^256 for SHA-256, or 2^122 for the random bits in a UUID v4). The result is often wildly different from intuition: with a 128-bit space, you only need around 2^64 (roughly 18 quintillion) random values before there's a 50% chance two of them match — far fewer than the 2^128 you might expect.
How to use it
- Pick a hash size from the dropdown (MD5, SHA-1, SHA-256, SHA-512, UUID v4, CRC32) or choose Custom bit size and set your own bit width.
- Enter the number of items you plan to generate. Plain numbers and scientific notation both work — type
1e9for a billion. - Read the probability of at least one collision for that many items.
- The table also always shows how many items it takes to reach a 50%, 1%, or 0.01% collision risk, plus a slider to look up the item count for any other target probability.
Why the math needs care
Working this out by hand (or asking a chat assistant to "just calculate it") usually breaks down at scale: 2^256 has 78 digits, and a naive calculator either overflows or silently truncates the exponent, giving a nonsense probability. This tool keeps every calculation in log2 space — the hash space itself is never materialized as a giant number — so it stays accurate no matter how large the hash size gets, and uses expm1 internally so very small collision probabilities don't get rounded away to zero.
How many items until a git commit SHA-1 or short database ID collides?
Same formula, smaller space. A 7-character short git hash is 28 bits — pick Custom bit size and set it to 28 to see how few commits it takes before short-hash collisions become likely. The same approach works for any auto-increment ID space, session token length, or shortlink slug you're sizing.
Privacy
Everything runs in your browser — the numbers you enter are never sent anywhere.
Related tools
If you're choosing a hash size to avoid this kind of collision in a real system, sizing your actual bit budget for a deliberate false-positive rate is a related problem — see the Bloom Filter Parameter Calculator. To generate the hashes themselves, use the Hash Generator or UUID Generator.