Developer Tools 8 min read • Updated 2026-10-12

UUIDs Explained: Structure, Collision Probability & Differences Between v1, v4 & v7

Learn how 128-bit Universally Unique Identifiers (UUIDs) are constructed, calculate the microscopic odds of a collision, and understand why UUID v7 is replacing v4 in modern databases.

By Dhaval Joshi, Lead Engineer & Founder of FreeToolkit

What Is a UUID?

A UUID (Universally Unique Identifier), standardized under RFC 4122 (and updated by RFC 9562), is a 128-bit identifier designed to guarantee uniqueness across distributed computing networks without requiring a central database coordination authority.

A standard UUID is represented as 32 hexadecimal digits separated by hyphens into five distinct groups: 8-4-4-4-12 (36 characters total including hyphens), for example:

550e8400-e29b-41d4-a716-446655440000
    │       │   │  │        │
    │       │   │  │        └── 48-bit Node identifier
    │       │   │  └─────────── 2-bit Variant + 14-bit Clock Sequence
    │       │   └────────────── 4-bit Version (e.g., 4 = v4)
    │       └────────────────── 16-bit Timestamp (middle)
    └────────────────────────── 32-bit Timestamp (low)

The Mathematics of UUID v4 Collisions

UUID version 4 utilizes 122 bits of pure pseudorandom entropy (6 bits are reserved for variant and version markers). The total number of possible UUID v4 combinations is 2^122 ≈ 5.3 × 10^36 (5.3 undecillion combinations).

To appreciate how astronomical this number is: if you generated one billion UUIDs every single second for 100 consecutive years, the probability of generating even a single duplicate ID is less than 0.00000000006%. You are thousands of times more likely to be struck by a meteorite while holding a winning lottery ticket.

The Evolution: UUID v1 vs v4 vs the New UUID v7

VersionGeneration MethodKey AdvantageDrawback
UUID v160-bit timestamp + MAC addressChronologically sortableSecurity leak: exposes device MAC hardware address and exact generation time.
UUID v4122 bits of random dataMaximum privacy & simplicityDatabase fragmentation: completely random keys shatter B-Tree index performance.
UUID v748-bit Unix millisecond timestamp + 74 bits randomTime-ordered & DB-optimizedRequires RFC 9562 library support.

Why UUID v7 is the future: Modern high-performance relational databases (PostgreSQL, MySQL InnoDB) rely on B-Tree indexes for primary keys. Inserting random UUID v4 keys causes constant page splits and cache evictions. UUID v7 prefixes each identifier with a millisecond timestamp, ensuring new records append naturally to the end of index leaf pages like auto-incrementing integers while preserving global distributed uniqueness.

Generate RFC-compliant identifiers securely in your browser using FreeToolkit's UUID Generator.

Written by Dhaval Joshi. Have feedback or questions? Contact us at support@freetoolkit.online.