What a ULID collision actually is
A ULID is 128 bits, written as 26 Crockford Base32 characters. The first 48 bits are a Unix timestamp in milliseconds. The other 80 bits are randomness. Two ULIDs can be equal only when both parts match, so a collision is possible only inside one shared millisecond.
That split is why a huge total over months is usually uneventful. The birthday problem does not run on the lifetime total. It runs on the IDs that land in the same millisecond, and that small chance is then repeated for every millisecond in the window.
The formula this page uses
Inside one millisecond, n random 80-bit suffixes are drawn from a space of d = 2^80 values. The chance of at least one repeated suffix is the birthday bound. For modest n it is about n(n-1) / 2^81, because 2 x 2^80 = 2^81. 2^80 is 1,208,925,819,614,629,174,706,176.
This calculator uses the close form n^2 / 2^81 per millisecond, which is a little higher than n(n-1) / 2^81. Let n be the fleet-wide count in one millisecond: the per-node rate converted to IDs per millisecond, multiplied by the node count. Let M be the number of milliseconds in the duration. A year is 365.25 days and a month is 30.4375 days, which is what the form uses. The chance of at least one collision anywhere in the window is about 1 - exp(-M x n^2 / 2^81). When that exponent is under 10^-6, the page prints the exponent itself, because 1 - exp(-x) is then indistinguishable from x.
The model assumes the rate is spread evenly, and that every node draws an independent random suffix. A burst that piles many IDs into a few milliseconds is riskier than the same average, because the chance grows with n squared.
Worked examples
One millisecond, 1,000 IDs. Using the tighter pair count: 1,000 x 999 / 2^81 = 4.13 x 10^-19. You would need on the order of a trillion IDs in that same millisecond before the chance becomes ordinary, and 2^40 is about 1.1 x 10^12.
The form's own defaults: 100 IDs per second on each of 10 nodes, for 5 years. That is 1 ID per millisecond across the fleet (100 / 1,000 x 10). M is 157,788,000,000 milliseconds. Total IDs are the same number, 157,788,000,000. The compounded chance is about 6.53 x 10^-14, roughly 1 in 15 trillion. With an average of one ID per millisecond, most milliseconds contain no pair at all, so the n^2 form is a slight overestimate here.
A rate that finally shows up on a calculator: 50,000 IDs in every millisecond for one day. M is 86,400,000. The exponent is about 8.93 x 10^-8, roughly 1 in 11.2 million. That is 50 million IDs per second. It is a fleet-sized number, not a single process.
When to use it
- You are choosing ULID as a primary key and want a number for the volume you actually expect, instead of a slogan about 80 bits.
- You want to see that the dangerous input is IDs per millisecond, not the row count of the table.
- You are comparing that model with Snowflake, where a collision is a coordination bug, or with UUID v4, where the birthday problem covers the whole history in one bucket.
Pitfalls
- Do not feed the lifetime total into one birthday formula. That pretends every ID was minted in a single millisecond and overstates the risk by an enormous factor.
- Monotonic ULIDs are a different model. Libraries that increment the random field inside one process do not collide with themselves until that 80-bit counter wraps, which it will not. Risk remains only between processes that are not coordinating.
- Clock rollback can reuse a millisecond. If the random field is also reset, the assumption of a fresh draw fails.
- The page does not look at a database. Equal inputs always produce the same estimate.
- Node count only matters if those nodes draw from the same 80-bit space in the same millisecond. A monotonic counter that is local to each process is not that model.
How the collision model differs
| Format | Where a duplicate can happen | What to measure |
|---|---|---|
| ULID (random suffix) | Same millisecond and same 80 random bits | IDs per millisecond, then repeat across the window |
| UUID v4 | Anywhere in the whole history | Lifetime count against 122 random bits (about n^2 / 2^123) |
| Snowflake | Same millisecond, same datacenter, same worker, same sequence | Worker-id clashes and sequence overflow, not a random birthday bound |
| CUID2 (official, length 24) | Anywhere, no time bucket | Length. A letter plus 23 base36 characters is about 124 bits |
Questions
Why can a ULID collide only inside one millisecond?
The first 48 bits are the timestamp. A different millisecond produces a different prefix, so the 80-bit suffixes are never compared across time. Equality needs both the prefix and the suffix.
What is 2^81 doing in the formula?
The random suffix has d = 2^80 possible values. The leading birthday term is n(n-1) / (2d). 2d is 2^81. The calculator uses n^2 / 2^81, which is the same idea and slightly conservative.
Is a chance of 10^-14 safe?
For identifiers, yes. It is far below rates that matter for a database key. The number to watch is how many IDs share a millisecond. An average near 1 is not a collision regime. Tens of thousands per millisecond, sustained, is where the exponent becomes visible, and it is still small.
Does a monotonic ULID change this?
Yes. A monotonic generator spends the random bits as a counter inside one process, so that process will not repeat a value in the same millisecond. This page models independent random draws. Use it for that design, not for a per-process counter.
Will this tell me if my table already has a duplicate?
No. It is a probability from the rate, the node count, and the duration you type. It does not connect to a database, and nothing you enter is uploaded.