UUID v4 vs. Other Versions: Why Almost Everyone Uses v4
Published 2026-09-14
UUIDs aren't all built the same way
A UUID is a 128-bit identifier, but the specification actually defines several different "versions" that generate those 128 bits in completely different ways. The version number is literally encoded into the UUID itself (it's one of the digits), so you can usually tell which kind of UUID you're looking at just by reading it.
The main versions, briefly
- Version 1 is built from the current timestamp and the network card's MAC address. It's sortable by creation time, but it leaks the machine's hardware identifier and creation time into every ID it generates — a privacy and security concern that made it fall out of favor.
- Version 4 is built almost entirely from random bits. It reveals nothing about when or where it was created, and the odds of two version-4 UUIDs ever colliding are so astronomically small that it's treated as effectively impossible in practice.
- Version 5 is generated deterministically from a namespace and a name (using a hash), so the same input always produces the same UUID — useful for generating a stable ID from, say, a URL, without a database lookup.
- Version 7 (newer, gaining adoption) combines a timestamp with random bits, giving both the sortability of v1 and much better randomness — a compromise some newer database systems now prefer.
Why v4 became the default
For most applications — database primary keys, API request IDs, session tokens — you don't need sortability or determinism, you just need a unique identifier that can be generated independently on any machine without coordination or without leaking information about the machine that created it. Version 4 does exactly that with the simplest possible design, which is why it became the practical default across most programming languages and frameworks.
How random is "random enough"?
A version-4 UUID has 122 random bits (6 of the 128 bits are fixed to mark the version and variant). To put that in perspective, you could generate a billion UUIDs every second for about 85 years and still have less than a one-in-a-billion chance of ever generating a duplicate. Our UUID Generator produces version-4 UUIDs using your browser's secure random number generator, matching the same randomness quality used for encryption keys.