Collision calculator
Estimate duplicate risk under a transparent birthday-bound model. The result is only as good as the uniform, independent-generation assumptions described below.
Opaque lowercase identifier, 24 characters
Installed package range: 2–32; default: 24
Understanding ID Collisions
A collision occurs when two independently generated IDs happen to be identical. While rare, understanding collision probability helps you choose the right ID format for your scale.
The birthday paradox
The "birthday paradox" is a famous probability puzzle: in a room of just 23 people, there's a 50% chance that two share a birthday. This seems counterintuitive because there are 365 possible birthdays.
The same principle applies to unique IDs. Collisions become probable much sooner than you might expect - roughly at the square root of the total possible ID space.
Here n is the number generated and N is the sample space. The calculator evaluates the expression with a numerically stable expm1 operation so tiny non-zero results are not rounded to zero during subtraction.
Reproducible worked examples
One million 24-character CUID2s
N = 26 × 36²³ ≈ 1.62155 × 10³⁷. The birthday-bound estimate is approximately 3.08346 × 10⁻²⁶.
One billion 16-character CUID2s
N ≈ 5.74792 × 10²⁴ and the estimate is approximately 8.69880 × 10⁻⁸. Set length to 16 and count to 1,000,000,000; the result URL records both inputs for reproduction.
ID Type Comparison
| Type | Modeled space | 50% Threshold |
|---|---|---|
| CUID2 (configurable 2–32) | 26 × 36L−1 | Changes with length |
| UUID v4 | 2¹²² | ~2.7 × 10¹⁸ IDs |
Why CUID v1 is absent: its timestamp, counter, fingerprint, and random fields do not form one uniform random space. Assigning it an unexplained “effective” space would produce a precise-looking but unsupported answer.
Sources and limitations
- CUID2's leading-letter rule and 24-character default come from the CUID2 implementation documentation.
- UUID v4 has 122 random bits after its fixed version and variant fields; see RFC 9562, section 5.4.
- The calculation models ideal output distributions. It cannot predict implementation defects, compromised randomness, cloned state, or operational duplication. A unique database constraint remains the final enforcement layer.