A map of every UUID version
A UUID is a 128-bit identifier written as 32 hexadecimal digits in the 8-4-4-4-12 pattern. The standards (RFC 4122, updated by RFC 9562) define several versions that differ in how those 128 bits are filled — some are purely random, some embed a timestamp, some embed a hash. Two fixed fields are common to all of them: the version nibble (the first digit of the third group) and the variant bits (the high bits of the fourth group). Everything else is what makes each version distinct.
How it works
Reading any UUID starts at two positions. The 13th hex digit is the version (1–8), and the 17th hex digit’s high bits are the variant — for the standard layout this digit is one of 8, 9, a or b. From there each version has its own recipe:
- Time-based versions (1, 6, 7) pack a clock value into the high bytes. v1 and v6 use a 60-bit count of 100-nanosecond intervals since 1582-10-15 plus a 48-bit node id; v6 reorders the timestamp so it sorts. v7 uses a simpler 48-bit Unix millisecond timestamp followed by random bits.
- Name-based versions (3, 5) hash a namespace UUID concatenated with a name — MD5 for v3, SHA-1 for v5 — so the same input always yields the same UUID.
- Random version (4) fills 122 bits from a cryptographic random source.
- Custom version (8) leaves all non-fixed bits to the implementer.
Tips and notes
For high-insert tables prefer a time-ordered UUID (v7, or v6 if you need the node component) so the index stays compact. Use v5 over v3 for name-based ids — SHA-1 is preferred over MD5 even though both are truncated to 128 bits. Never expose a v1 UUID where the embedded MAC address or timestamp would leak information; v4 or v7 avoid revealing hardware identity. The nil UUID (all zeros) and the max UUID (all fs) are reserved sentinels, not generated values.