UUID Versions Explained
The UUID specification defines multiple versions with different generation methods. Choosing the right version depends on your requirements for uniqueness, privacy, reproducibility, and performance. This guide compares all versions to help you decide.
Version 1 - Time-based
Version 1 UUIDs are generated using the current timestamp and the machine's MAC address. This combination guarantees uniqueness: no two machines have the same MAC address, and the timestamp ensures the same machine never generates duplicates. The timestamp uses a 60-bit value representing 100-nanosecond intervals since October 15, 1582 (the start of the Gregorian calendar). This provides sub-microsecond precision and enough range for millennia of unique IDs. The 48-bit MAC address uniquely identifies the network interface. Benefits of V1 UUIDs: Guaranteed uniqueness without randomness (deterministic generation). Natural chronological ordering—you can sort V1 UUIDs by creation time. When things go wrong, the timestamp and MAC can help debug where and when an ID was created. Drawbacks of V1 UUIDs: Privacy concerns—the MAC address reveals information about the generating device (manufacturer, network interface), and the timestamp reveals when the ID was created. This can be exploited for tracking or timing attacks. Systems without network interfaces (or with spoofed MACs) can't generate compliant V1 UUIDs. Some implementations use a random node ID instead of the MAC address for privacy, though this deviates from the spec and introduces collision risk. Implementations also handle the "clock moved backwards" problem differently, which can occur with NTP adjustments. Use V1 when: You need time-based ordering, you're in a controlled environment where privacy isn't a concern (internal systems), or you're working with systems that specifically require time-based UUIDs. For most new applications, V4 (random) is preferred.
Version 4 - Random
Version 4 UUIDs are generated using random or pseudo-random numbers. All 122 bits (the remaining 6 are used for version and variant markers) are randomly generated, providing approximately 5.3 × 10^36 possible values. The generation process is simple: generate 128 random bits, set the version (4 bits indicating V4), set the variant (2 bits), and format as the standard UUID string. The simplicity means V4 is easy to implement correctly, and high-quality random number generators are widely available. Benefits of V4 UUIDs: Maximum privacy—no information about when or where the ID was generated is encoded. Simple implementation—just needs a good random source. No coordination needed—any system can generate V4 UUIDs independently. Widely supported in libraries and databases. The collision probability is astronomically low. You would need to generate 2.71 × 10^18 UUIDs (2.71 quintillion) to have a 50% chance of a single collision. In practical terms: if you generated one million UUIDs per second, it would take about 86 years to reach a 50% collision probability. For virtually all applications, V4 collisions are not a concern. The quality of randomness matters. Use cryptographically secure random number generators (CSPRNG), not Math.random() or weak PRNGs. Our generator uses the Web Crypto API's getRandomValues(), which provides cryptographic-quality randomness. Use V4 when: You want the simplest and most private option (most applications). You don't need time-based ordering. You have access to a good random source. This is the default choice for new applications.
Version 5 - Name-based
Version 5 UUIDs are generated by hashing a namespace UUID together with a name using SHA-1. The same namespace and name always produce the same UUID, making V5 useful for creating reproducible identifiers from known inputs. The generation process: concatenate a 16-byte namespace UUID with the name bytes, hash the result with SHA-1, take the first 128 bits of the hash, set the version and variant bits. The namespace ensures that the same name in different contexts produces different UUIDs. Predefined namespaces exist for common use cases: DNS (6ba7b810-9dad-11d1-80b4-00c04fd430c8) for domain names, URL (6ba7b811-9dad-11d1-80b4-00c04fd430c8) for URLs, OID (6ba7b812-9dad-11d1-80b4-00c04fd430c8) for ISO OIDs, X.500 DN (6ba7b814-9dad-11d1-80b4-00c04fd430c8) for X.500 names. You can also create your own namespace UUID for custom applications. Benefits of V5 UUIDs: Reproducibility—same inputs always give the same output. Derivability—given the namespace and name, anyone can compute the UUID. No storage needed—the UUID can be computed on demand from its inputs. Deterministic—useful for testing and debugging. Version 3 is identical but uses MD5 instead of SHA-1. Since MD5 is cryptographically broken, Version 5 is preferred for new applications. Note that neither V3 nor V5 provides security—the UUID can be reversed to find the name if the namespace is known and the name space is small. Use V5 when: You need to create UUIDs from existing identifiers (URLs, emails, resource names). You want multiple systems to independently derive the same UUID for the same resource. You're building content-addressable or deduplication systems.
Try UUID Generator
Put this knowledge into practice