UUID Versions Guide: v1 vs v4 vs v5 vs v7 Compared
Not all UUIDs are generated the same way. Here's exactly how each version works, and a clear answer for which one fits your specific use case.
Version 1: Timestamp + Node
UUID v1 combines the current timestamp (100-nanosecond intervals since October 15, 1582 — the Gregorian calendar's start date, chosen for historical compatibility with earlier timestamp systems) with a node identifier, originally the machine's MAC address. This makes v1 UUIDs naturally sortable by creation time, but the original MAC-based approach leaked hardware identity information — most modern implementations now use a random node ID instead to avoid this privacy issue.
Version 4: Random
The most widely used version. 122 bits are filled with cryptographically random data (6 bits are fixed to mark version and variant). No ordering, no embedded information — purely random, offering the strongest privacy of any version since nothing about when or where it was generated can be inferred.
Version 5: Name-Based (Deterministic)
Generated by SHA-1 hashing a namespace UUID combined with a name string. Critically, v5 is deterministic — the same namespace and name always produce the exact same UUID. This makes it useful for generating a stable, repeatable identifier from existing data, like turning a URL or email address into a consistent UUID without needing to store a separate mapping table.
Version 7: Sortable Random
The newest widely-adopted version, combining a millisecond-precision Unix timestamp prefix with random bits for the remainder. This gives v7 the best of both worlds: chronological sortability like v1, without the node-identifier privacy concerns, plus strong randomness in the non-timestamp portion. Database index performance benefits significantly since new v7 values append in roughly ascending order rather than scattering randomly like v4.
Side-by-Side Comparison
| Version | Sortable | Deterministic | Privacy | Index-Friendly |
|---|---|---|---|---|
| v1 | Yes | No | Weaker (timestamp exposed) | Yes |
| v4 | No | No | Strongest | No — fragments indexes |
| v5 | No | Yes (from same input) | Depends on input | No |
| v7 | Yes | No | Strong | Yes |
Which Version Should You Use?
- Building a new system with no legacy constraints: v7 is increasingly the recommended default — sortable, index-friendly, and privacy-respecting.
- Need a stable ID derived from existing data (like a URL): v5, since the same input always regenerates the same UUID without needing a lookup table.
- Maximum unpredictability, no ordering needed: v4 remains the safe, universally-supported default, especially for session tokens or API keys where guessability matters most.
- Working with a legacy system already using v1: Stick with v1 for consistency unless you have a specific reason to migrate.
Generate v1 or v4 UUIDs instantly with our UUID Generator.
FAQs
ToolsNovaHub guides are researched against primary sources (RFCs, vendor docs) and kept up to date as standards change. Spotted an error? Let us know.
📋 Related Tools & Guides Comparison
| Resource | Type | Link |
|---|---|---|
| UUID Generator | Tool | Open Tool → |
| UUID vs GUID Explained | Guide | Read Guide → |
| UUID Primary Key Guide | Guide | Read Guide → |
| MAC Address Generator | Tool | Open Tool → |