The Bloom Filter Calculator demonstrates how a Bloom filter tests membership. Add items, then test whether new items are possibly present or definitely absent.
Bloom Filter Calculator
Optimal Bloom filter sizing — m bits and k hashes for your item count and error budget, verified after rounding.
Enter your values
Fill in the fields below — the result appears with every step shown.
Your result will appear here
Enter your values above, then press Calculate — or press Enter in any field.TinyExe · Bloom Filter Result
Calculated locally in your browser
—
Name
—
Expected number of items (n)
—
Target false positive rate (p, as a decimal)
—
Result
—
How this was calculated
What to do next
TinyExe PDF & PNG exports carry the TinyExe logo and tinyexe.com header & footer.
Runs 100% in your browser — your numbers never leave this tab; nothing is uploaded or stored.
The short answer
The optimal Bloom filter size is m equals minus n times ln p, divided by (ln 2) squared, with k equals (m/n) times ln 2 hash functions. For 1,000 items at a 1 percent false positive rate, m is 9,586 bits and k is 7, using roughly 9.6 bits per item stored.
- m = -(n ln p)/(ln 2)^2 bits
- k = (m/n) ln 2 hash functions
- 1% error costs about 9.6 bits per item
Bits per item by target false positive rate
Reference values for this calculator.
| Target p | Bits per item (approx) | Optimal k |
|---|---|---|
| 10% | 4.8 | 3 |
| 5% | 6.2 | 4 |
| 1% | 9.6 | 7 |
| 0.1% | 14.4 | 10 |
| 0.01% | 19.2 | 13 |
The formula
The exact formula this calculator uses — every variable in it is explained in the card below.
The formula
A Bloom filter trades a tunable false-positive rate for dramatic memory savings. This tool uses the standard optimal sizing formulas (Bloom 1970; Broder-Mitzenmacher survey) and then verifies the design by computing the achieved false positive rate from the rounded m and k — the step most quick calculators skip, and the reason naive integer rounding can silently miss the target rate.
Worked examples
Worked examples with the full working shown — try them in the calculator to check.
Example 1
Classic sizing
n = 1,000 items, p = 0.01 (1%)
| Calculation | Steps |
|---|---|
| m = -(1000 x ln 0.01)/0.4805 = 9,585.1 → 9,586 bits. k = (9.586) x 0.693 = 6.64 → 7. | m = 9,586 bits (about 1.2 KB), k = 7. |
Result
Example 2
Small filter, looser target
n = 100 items, p = 0.05 (5%)
| Calculation | Steps |
|---|---|
| m = -(100 x ln 0.05)/0.4805 = 623.4 → 624 bits. k = 6.24 x 0.693 = 4.32 → 4. | m = 624 bits, k = 4. |
Result
Example 3
Large, strict filter
n = 10,000 items, p = 0.001 (0.1%)
| Calculation | Steps |
|---|---|
| m = -(10000 x ln 0.001)/0.4805 = 143,775.9 → 143,776 bits. k = 14.38 x 0.693 = 9.97 → 10. | m = 143,776 bits (about 18 KB), k = 10. |
Result
How to use this calculator
Step 1
Enter n, the number of items the filter must hold.
Step 2
Enter p, the false positive rate you can tolerate, as a decimal (0.01 = 1%).
Step 3
Press Calculate.
Step 4
Provision m bits and k hash functions; check the achieved rate matches your target.
Frequently asked questions
What is a Bloom filter?
A space-efficient probabilistic set: a bit array plus k hash functions. It can say "definitely not present" or "probably present" — false positives are possible, false negatives never are. It is used in databases, caches and spell checkers.
How big should a Bloom filter be?
For n items and target false positive rate p, the optimum is m = -(n ln p)/(ln 2)² bits — about 9.6 bits per item for 1% — with k = (m/n) ln 2 hash functions, about 7 at that size.
Why does k matter?
Too few hashes under-fill the bit array; too many set too many bits and raise collisions. The optimum k balances the array at about half-full at capacity, which minimises false positives.
Can a Bloom filter give a wrong "yes"?
Yes, by design — that is the false positive rate you choose and pay memory for. It can never give a wrong "no": if any of the k bits is 0, the item was certainly never inserted.
What happens if I insert more than n items?
The bit array fills beyond the design point and the real false positive rate climbs above target, quickly at first. Size for peak expected items, or use a scalable/counting variant.
About this calculator
The Bloom Filter Calculator sizes a Bloom filter optimally: given the number of items you expect to store and the false positive rate you can tolerate, it returns the bit-array size m, the number of hash functions k, the bits per item, and the false positive rate the rounded design actually achieves.
A Bloom filter stores no items at all — just bits flipped by hashing. Membership asks whether all k bits for an item are set: a single 0 proves absence, while all 1s mean "probably present", because other items may have set those bits by collision. That asymmetry (no false negatives, rare false positives) is exactly what pre-filters need before an expensive lookup.
The sizing maths has a sweet spot. Adding bits lowers collisions; adding hashes checks more bits but also sets more. The optimum that minimises false positives for a given memory sets the array about half full at capacity, giving m proportional to n log(1/p) — the reason each extra factor of 10 in accuracy costs only about 4.8 more bits per item.
Use it when designing caches, database indexes (LSM-tree stores like Cassandra and RocksDB use Bloom filters per SSTable), URL blocklists, or any membership test where storing the full set costs too much memory.
How to calculate it yourself
Step 1
Decide n (expected items) and p (tolerable false positive rate).
Step 2
Compute m = -(n ln p) / (ln 2)² and round UP to whole bits.
Step 3
Compute k = (m/n) ln 2 and round to the nearest whole hash count (minimum 1).
Step 4
Optionally verify: achieved p ≈ (1 - e^(-kn/m))^k.
Step 5
Provision m/8 bytes of memory.
Real-life examples
Sizing a URL blocklist filter
A browser team wants a local pre-filter for 1 million known-bad URLs at 1% false positives before consulting the server list.
m = -(1,000,000 x ln 0.01)/0.4805 ≈ 9,585,059 bits ≈ 1.2 MB; k = 7.
A 1.2 MB filter replaces a multi-hundred-MB full list on device — the classic Bloom filter win.
Cache admission in a key-value store
An engineer budgets 10 bits per key for a cache holding 500,000 keys and wants to know what error rate that buys.
m/n = 10 gives p ≈ 0.6185^(10 x 0.693)... the inverse check: k = 7, achieved p ≈ (1 - e^(-0.7))^7 ≈ 0.0082, about 0.8%.
10 bits per key buys roughly a 1% false positive rate — acceptable for cache admission.
Ideas & use cases
- Price accuracy: run p = 0.01 and p = 0.001 for the same n to see memory grow by about 4.8 bits per item per 10x accuracy — then decide what the accuracy is worth.
- Avoid the overfill trap: size for the 95th-percentile item count, not the average; an overfilled filter silently degrades.
- Compare against a hash set: a 64-bit hash set costs 64 bits per item with near-zero false positives — Bloom wins below about 20 bits per item at equal accuracy.
Limitations & sources
- Classical static Bloom filter sizing for a fixed expected n. Counting, scalable and partitioned variants differ; the achieved-rate figure uses the standard independence approximation for the hash functions.
Sources: Bloom, B. (1970), Space/time trade-offs in hash coding with allowable errors, CACM 13(7); Broder & Mitzenmacher (2004), Network applications of Bloom filters: a survey
