Updated July 1, 2026
UUID versions reference
UUIDs come in several versions that differ in how the value is generated. This sheet summarizes the common ones so you can pick the right version for keys, references, or tracing.
Versions
| Version | Based on | Time-ordered | Typical use |
|---|---|---|---|
v1 | Timestamp + MAC address | Yes (with quirks) | Legacy; can leak the machine's MAC |
v4 | Random | No | General-purpose default; unpredictable |
v5 | Namespace + name (SHA-1) | No | Deterministic ID from the same input |
v7 | Unix timestamp + random | Yes | Database keys — sorts by creation time |
Format is the same for all versionsEvery UUID is 128 bits shown as 32 hex digits in an 8-4-4-4-12 pattern. The version only changes how the bits are produced, not the length or shape.
v4 vs v7 for keysRandom
v4 scatters inserts across a database index, which can hurt write performance at scale. Time-ordered v7 keeps new rows near each other, so it is usually the better primary key.References
Questions
Which UUID version should I use?
Use v4 for general random identifiers. Use v7 when the UUID is a database primary key, because its time ordering keeps indexes efficient. Use v5 when you need the same input to always map to the same ID.
Is UUID v7 better than v4?
For database keys, usually yes, because v7 is time-ordered and reduces index fragmentation. For opaque, unguessable tokens, v4's full randomness can be preferable.