Skip to content
gohacks.dev
Architecture

ID Collision Probability Calculator

Calculate the chance that randomly generated IDs collide, from their bits or their alphabet and length, and how many IDs reach a 1% or 50% chance.

Free · No sign-up · Your inputs stay in your browser

Input

How likely is an ID collision?

Output

Chance of at least one collision: 5.88e-21

Entropy126.0 bits
Possible values2^126.0
IDs for a 1% chance1.31e+18
IDs for a 50% chance1.09e+19

The birthday bound: with N possible values, n random IDs collide with probability about 1 − e^(−n²/2N), so collisions arrive around √N, far sooner than N. A UUIDv4's 122 random bits need about 2.7 × 10^18 IDs for a 50% chance. Short codes are where it bites: a 6-digit code collides with 50% likelihood after only about 1,200 draws. For UUIDv7, the random bits only have to be unique within one millisecond.

Runs in this browser. Nothing you paste is sent to a server.

The birthday bound

Collisions arrive at around the square root of the number of possible values, much sooner than intuition suggests. A UUIDv4's 122 random bits need about 2.7 × 10^18 ids for an even chance, which is why they are treated as unique. A 6-digit code reaches 50% after about 1,200 draws, which is why short codes need a uniqueness check.

Time-ordered ids

UUIDv7 and ULID use part of their bits for a timestamp, so only ids generated in the same millisecond can collide, and the random bits only need to be unique within that window. RFC 9562 describes the layouts.

Share

Frequently asked questions

Do I still need a unique index with UUIDs?
Keep it. The probability of a random collision is negligible, but a bug that reuses or copies ids is not, and the index catches it.
How long should a short code be?
Enough that the expected number of ids stays far below the square root of the space, and always with a uniqueness check on insert.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools