The Tale of the UUID
DEEP DIVE — WHAT DO THE VARIANT BITS SELECT?▾
The first digit N of the 4th group is a prefix code — read it first, and it tells you which layout rulebook applies.
| FIRST DIGIT | TOP BITS | VARIANT — LAYOUT | STATUS |
|---|---|---|---|
| 0 – 7 | 0xxx | Var 0 — NCS / Apollo | legacy, extinct |
| 8 9 a b | 10xx | Var 1 — RFC 4122 / 9562 | the standard — what you use |
| c – d | 110x | Var 2 — Microsoft GUID | legacy Windows/COM |
| e – f | 111x | Var 3 — reserved | reserved for the future |
The variant is a prefix code, like the lead bits in UTF-8: it uses only as many bits as it needs to stay unambiguous. Variant 1 grabbed the shortest free prefix (10), spending just 2 bits so the rest stays open for the version + randomness — the legacy variants "cost" 3 bits because they got longer prefixes. This is what makes a UUID self-describing: any parser reads these bits first to know the layout, so the format can keep evolving (v1 → v4 → v7 → v8…) without anyone ever needing to be told which rulebook applies.
1 · Peace between rival standards. UUIDs were invented three times — Apollo's NCS, Microsoft's GUID, and the OSF/RFC layout — and all three print as the same hex string but arrange their bytes differently. The variant tag says whose rulebook to read, so incompatible formats coexist in one bit-space with no central registry.
2 · Future-proofing. Variant 3 (111x → e/f) is left reserved on purpose — an escape hatch. If a genuinely new layout is ever needed, there's an unclaimed prefix waiting, and old parsers will at least see "a variant I don't understand" instead of silently misreading the fields.
Reality check: in practice almost everything today is Variant 1 — you'll basically never branch code on this. It's a fossil of UUID's messy multi-vendor history plus a little reserved headroom.
| TOTAL UUIDS EVER MADE | CHANCE OF ANY COLLISION |
|---|---|
| 1 billion | ~1 in 10¹⁹ |
| 1 trillion | ~1 in 11 trillion |
| 1 quadrillion | ~1 in 11 million |
| 2.7 quintillion | ≈ 50% |
| 10 quintillion | ≈ certain |