Bloom Filter Size Calculator
A Bloom filter is a space-efficient probabilistic data structure that tests whether an element is a member of a set. It can return false positives but never false negatives. To size one correctly you need to choose a bit array length and a number of hash functions that meet your target false positive rate for the number of items you expect to store. This calculator applies the standard sizing formulas to turn your expected item count and target false positive probability into the optimal bit array size, the optimal number of hash functions, and the memory footprint in bytes.
Bloom filter sizing formula
m = ceil( -(n * ln(p)) / (ln 2)^2 )
k = round( (m / n) * ln 2 )
bits per element = m / n
bytes = ceil( m / 8 )
Here n is the expected number of stored items, p is the target false positive probability (between 0 and 1), m is the bit array size, and k is the number of hash functions. The bit array size m grows with both the item count and the demand for a lower false positive rate. The optimal k depends only on the ratio m/n.
Worked example
For n = 1,000,000 items at p = 0.01 (a 1% false positive rate): m = -(1,000,000 * ln 0.01) / (ln 2)^2 = -(1,000,000 * -4.60517) / 0.480453 = 9,585,059 bits. That is 1,198,133 bytes (about 1.14 MiB) and 9.59 bits per element. The optimal k = round((9,585,059 / 1,000,000) * 0.693147) = round(6.64) = 7 hash functions.
Bloom filter sizing: frequently asked questions
What is the optimal bit array size for a Bloom filter?
The optimal number of bits m for n items at a target false positive probability p is m = -(n * ln(p)) / (ln(2))^2. This is the standard result derived in the literature on Bloom filters. Dividing m by n gives the bits per element, which depends only on the target false positive rate, not on the absolute number of items.
How many hash functions should a Bloom filter use?
The optimal number of hash functions k that minimises the false positive rate for a given m and n is k = (m / n) * ln(2). In practice you round k to the nearest whole number, since a filter must use an integer number of hash functions. Using more or fewer than the optimum increases the false positive rate.
What false positive rate should I target?
It depends on your application. A common choice is 1% (0.01), giving about 9.6 bits per element and roughly 7 hash functions. Lower rates need more memory: 0.1% needs about 14.4 bits per element. A Bloom filter never produces false negatives, only false positives, so choose a rate your downstream check can tolerate.
Does a Bloom filter ever give a wrong negative answer?
No. A Bloom filter can report a false positive (saying an item may be present when it is not) but never a false negative. If the filter says an item is absent, it is definitely absent. This is why Bloom filters are used as a cheap pre-filter before a more expensive exact lookup.
Sources and method
- Burton H. Bloom, "Space/Time Trade-offs in Hash Coding with Allowable Errors," Communications of the ACM, 1970. The original definition of the data structure.
- The optimal m and k expressions are standard mathematical results derived directly from the false positive probability of a Bloom filter; this tool computes them, it does not estimate them.
Reviewed by the CalculatorHub team, edited by James Graham, 19 June 2026. See our methodology.