Bloom Filter Calculator

Enter the expected element count and false positive rate to get the optimal bit array size m and hash function count k for your Bloom filter.

Use the Bloom Filter Calculator

Filter Parameters

How many distinct items will be inserted

Enter as a percentage — e.g. 1 means 1 in 100 false positives

Optimal Parameters

Bit array size

—

bits (m)

Hash functions

—

functions (k)

m = −n · ln(p) / (ln 2)²   |   k = (m / n) · ln 2

Details

Memory (bytes) —
Memory (human) —
Bits per element (m / n) —
Actual false positive rate (after rounding) —
Exact m (before rounding) —
Exact k (before rounding) —

Expected Bit Fill Rate

Fraction of bits set to 1 after inserting n elements: 1 − e^(−kn/m) — optimal Bloom filters aim for ~50%.

0% — 100%

Summary

A Bloom filter uses a bit array of size m and k independent hash functions to provide fast, memory-efficient set membership tests with a tunable false positive rate. This calculator applies the standard optimal formulas — m = −n·ln(p)/(ln 2)² and k = (m/n)·ln 2 — to tell you exactly how large to make the array and how many hash functions to use for any combination of expected elements and target accuracy.

How it works

  1. Enter the expected number of elements (n) you will insert into the filter.
  2. Set the desired false positive rate (p) as a percentage, such as 1% or 0.1%.
  3. The tool computes the optimal bit array size m = −n · ln(p) / (ln 2)² and rounds up to the nearest integer.
  4. It also computes the optimal hash function count k = (m/n) · ln 2, rounded to the nearest integer.
  5. Review memory usage, actual false positive rate after rounding, and bits per element.
  6. Adjust either input to explore the size–accuracy trade-off interactively.

Use cases

  • Size a Bloom filter for a caching layer to reduce unnecessary database lookups.
  • Design a duplicate-URL filter for a web crawler within a fixed memory budget.
  • Choose hash function count and bit array size for a distributed key-value store.
  • Estimate memory cost before implementing a Bloom filter in an embedded system.
  • Verify that a published Bloom filter configuration is mathematically optimal.
  • Teach probabilistic data structures by exploring the n–m–k–p relationship.

Frequently Asked Questions

Last updated: 2026-06-11 · Reviewed by Nham Vu