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

Model assumptions: IDs are independent and uniformly distributed over the stated space. CUID2 uses 26 × 36L−1 format-compatible values because the first character must be a letter; UUID v4 uses 2122 values after fixed version and variant bits.

Collision probability

3.08 × 10^-26

raw approximation: 3.083462736904e-26

~ 1 in 3.24 × 10^25 chance
ID space size
~1037
50% risk at
4.74 × 10^18 IDs

Risk comparison

CUID2 (24)
3.08 × 10^-26
UUID v4
9.40 × 10^-26
This is a theoretical birthday-bound estimate, not a guarantee. It does not model faulty random sources, implementation bugs, duplicated application state, retries, or database constraints. CUID v1 is omitted because its timestamp, counter, fingerprint, and random fields are structured rather than independent uniform draws from one documented space.
Calculation for this result: N = 26 × 36^23 = 1.621551945531e+37 possible values; p ≈ −expm1(−n(n−1)/(2N)). Percentages at or above 0.01% use fixed decimals; smaller non-zero values use scientific notation so they are never displayed as zero.

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.

Birthday-bound approximation
p ≈ 1 − e−n(n−1)/(2N)

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

TypeModeled space50% Threshold
CUID2 (configurable 2–32)26 × 36L−1Changes with length
UUID v42¹²²~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.