Collision probability calculator

How many random identifiers you can generate before a duplicate becomes likely, for any alphabet and length.

Presets

The formula, and the mistake almost everyone makes

This is the birthday problem. With a space of S possible values and n draws, the probability that at least two match is approximately 1 - exp(-n^2 / 2S), and the number of draws needed to reach probability p is approximately sqrt(2S ln(1/(1-p))).

The mistake is comparing figures computed at different probabilities. The widely linked Nano ID collision calculator reports the number of IDs for a 1 percent chance of a collision. Most blog posts and the CUID2 documentation quote the 50 percent birthday bound. Those two numbers differ by a factor of about sqrt(ln 2 / ln(1/0.99)) = 8.3 for the same bit count, so an article that mixes them will look like it is comparing two formats when it is really comparing two thresholds. This calculator shows both.

One more caveat worth stating: this arithmetic assumes the values are genuinely uniform and independent. If the generator has modulo bias, or if several machines start from the same seed, the real collision rate can be far higher than any of these numbers while the maths still looks reassuring. That is why the distribution matters more than the bit count. Our test results are here.