Blog
Wild & Free Tools

UUID v4 Collision Probability — Is a UUID Really Unique?

Last updated: March 2026 5 min read
Quick Answer

Table of Contents

  1. The Math Behind UUID Uniqueness
  2. The Real Risk: Bad Random Number Generators
  3. UUID Collision vs. Hash Collision
  4. Practical Takeaways
  5. Frequently Asked Questions

UUID v4 collisions are theoretically possible but practically impossible at any realistic scale. The format gives you 122 bits of randomness — 5.3 undecillion unique values — and the math works out to about a 50% collision chance only after generating 2.7 quintillion UUIDs. Here is exactly what the numbers mean and when you should care.

The Math Behind UUID v4 Uniqueness

A UUID v4 looks like this: 550e8400-e29b-41d4-a716-446655440000

128 total bits, but 6 bits are fixed version/variant markers, leaving 122 random bits. That gives:

The birthday paradox formula for the number of UUIDs needed to reach a 50% collision probability:

n ≈ sqrt(2 × ln(2) × 2^122)
n ≈ 2.71 × 10^18  (2.71 quintillion)

At 1 billion UUIDs generated per second, reaching that number would take 86 years. No application ever comes close.

UUIDs GeneratedCollision Probability
1,0001 in 1027 (unmeasurably small)
1 million1 in 1021
1 billion1 in 1015
1 trillion1 in 109 (1 in a billion)
2.71 quintillion~50% (birthday paradox threshold)

The Real Risk: Bad Random Number Generators

The birthday paradox math assumes truly random bits. If your random number generator is weak, predictable, or seeded with low-entropy values, collisions become far more likely — and the issue is not the UUID format itself, it is the generator.

What makes a UUID generator safe:

Safe generators (crypto-secure):

Python:   uuid.uuid4()  # uses os.urandom()
Node.js:  crypto.randomUUID()  # built-in, crypto-secure
Browser:  crypto.randomUUID()  # available in modern browsers
Go:       google/uuid  # reads from crypto/rand
Sell Custom Apparel — We Handle Printing & Free Shipping

UUID Collision vs. Hash Collision — Different Problems

UUID collision and hash collision are often confused but they are completely different scenarios.

UUID collision means two independently generated UUIDs happen to be identical. With v4, this requires both generators to randomly pick the same 122-bit value. Probability: astronomically small.

Hash collision (relevant to UUID v3 and v5, which use MD5 and SHA-1) means two different inputs produce the same UUID output. These versions are deterministic — same input always produces the same UUID. The collision concern is about whether two different strings could map to the same UUID, which is the hash collision problem and is more relevant for cryptographic attack scenarios than accidental collisions.

For most developers generating IDs for database records, v4 is the right choice. It is random, it is fast, and the collision risk is not worth thinking about at any realistic application scale.

Practical Takeaways for Developers

Here is what the collision math actually means for your application:

Need a UUID right now? The WildandFree UUID Generator uses crypto.randomUUID() in your browser — fully crypto-secure, no server involved.

Generate a Collision-Safe UUID Right Now

Our UUID generator uses your browser's built-in crypto-secure random source — the same standard used by every major UUID library. No server, no signup, one click.

Open Free UUID Generator

Frequently Asked Questions

Can two UUIDs ever be the same?

Mathematically yes, practically no. UUID v4 has 122 random bits. The probability of any two independently generated UUIDs being identical is roughly 1 in 5.3 undecillion. You would need to generate trillions of UUIDs before the risk becomes measurable.

Should I check for UUID collisions in my database?

Add a UNIQUE constraint on your UUID column as standard database hygiene, but do not write application-level collision detection logic. The constraint will catch any duplicate (from any source) while adding negligible overhead. At realistic data volumes, the constraint will never fire due to a true UUID collision.

Are UUID v7 collisions less likely than UUID v4?

They are essentially the same. UUID v7 uses a timestamp prefix plus random bits. The timestamp reduces the total random space slightly, but the remaining random bits still make collisions effectively impossible at any real scale. The timestamp component improves database insert performance (sequential ordering), not uniqueness.

What if my random number generator is broken?

If your language runtime or OS random source has a bug, UUID uniqueness breaks down completely — all generated UUIDs could be identical. This happened in real systems (PHP in early versions, some Java VMs in VMs after cloning). Always use your language's crypto-secure UUID library rather than building your own generator.

Jennifer Hayes
Jennifer Hayes Business Documents & PDF Writer

Jennifer spent a decade as an executive assistant handling every type of business document imaginable.

More articles by Jennifer →
Launch Your Own Clothing Brand — No Inventory, No Risk