Skip to content
shortuuid

ID collision calculator

How many random IDs can you make before two are the same? Pick an alphabet and length, or a UUID version, and the number of IDs. The calculator gives the entropy, the exact chance of at least one duplicate, and the counts where the risk passes 1 in a million or 50%.

Runs 100% in your browser — nothing is uploaded

IDs
Presets:

entropy = L × log₂(A) = 8 × log₂(62) = 47.63 bits · 2.18 × 10¹⁴ possible values

20,000,000 IDs

Chance of at least one collision

60%

1 − e^(−n(n−1)/2N); exact to many digits at this size.

Expected duplicate pairs

0.916

n(n−1)/2N: the average number of colliding pairs.

50% chance at

17.4 million

About 1.18 × √N IDs, the birthday bound.

0%25%50%75%100%110100100010⁴10⁵10⁶10⁷10⁸10⁹number of IDs (log scale)
Chance of at least one duplicate as the number of IDs grows. The dot is your count; hover the chart to read any point.

How many IDs until…

1 in a billion chance661
1 in a million chance20,897
1% chance2.09 million
50% chance17.4 million
99% chance44.8 million

Sample IDs (8 × 62 characters)

Made with crypto.getRandomValues, skipping bytes that would make some characters more likely than others.

Common ID formats

FormatRandom bitsIDs for a 1-in-a-million chanceIDs for a 50% chanceNote
22 random Base62 characters131.073.6 quadrillion6.13 × 10¹⁹A random ID as long as a short UUID
Nano ID (21 × 64 characters)12613 quadrillion1.09 × 10¹⁹Nano ID's default
UUID v41223.26 quadrillion2.71 × 10¹⁸In any encoding, short or long
ULID801.55 billion1.29 trillionIDs made in the same millisecond
UUID v774194 million162 billionIDs made in the same millisecond
11 × Base64 characters6612.1 million10.1 billionThe length of a video ID on a well-known site
8 × Base62 characters47.620,89717.4 millionA typical URL shortener
8 hex characters329377,163A 32-bit number, or the start of a UUID
6 × Base36 characters31.06654,933A short code people type in

For time-based IDs (ULID, UUID v7), only IDs made in the same millisecond can collide, so the counts are per millisecond across all generators. A generator that counts within a millisecond, as RFC 9562 allows, can't collide with itself at all.

The math

Entropy. A random string of length L from an alphabet of A characters can be any of AL values, which is L × log₂(A) bits. Each Base62 character is worth 5.95 bits, each Base64 character 6, each hex digit 4. That only holds if every character is chosen independently and uniformly by a secure random generator: a timestamp, a counter or a biased generator gives fewer bits than the formula says.

Collisions. With N = 2bits possible values, the chance that n IDs are all different is (1 − 1/N)(1 − 2/N)…(1 − (n−1)/N). The calculator multiplies that out (as a sum of logarithms) for up to a million IDs. Beyond that, it uses the standard approximation

P ≈ 1 − e^(−n(n−1) / 2N)

which comes from 1 − x ≈ e−x for small x. It's an approximation, not an exact formula, but for any realistic ID space its error is far too small to show. The surprise of the birthday paradox is the square root: the chance reaches 50% at about 1.18 × √N IDs, not at N/2. With 365 birthdays, 23 people are enough; with 47.6 bits (8 Base62 characters), 17 million IDs are.

What a collision costs. If the ID is a database primary key, a duplicate is usually a failed insert that can simply be retried with a new ID; a unique index catches it. It's worse when IDs are checked nowhere, like file names in object storage or tokens in links, where a duplicate silently overwrites or exposes something. Choose the length for the case you can't detect.

Converting a UUID to a short UUID doesn't change any of this: it's the same number in fewer characters.