UUID generator · Guide

UUID Generator Algorithm: How Each Version Is Built

All UUIDs are 128 bits with the same two fixed fields. What differs is where the other 122 bits come from — and that choice is the entire distinction between versions.

The fields every version shares

Four bits encode the version and two encode the variant. In the canonical form, the version is the first character of the third group and the variant is the first character of the fourth:

Text
xxxxxxxx-xxxx-Vxxx-Nxxx-xxxxxxxxxxxx
              ^    ^
              |    variant: 8, 9, a or b for RFC 9562
              version: 1, 3, 4, 5, 6, 7 or 8

A generator that produces 128 random bits without setting these fields makes a value that is not a UUID and that strict validators reject.

v1 — timestamp and MAC address

60 bits of 100-nanosecond intervals since 1582, a 14-bit clock sequence, and the 48-bit network MAC address. Uniqueness comes from the hardware address rather than randomness.

It leaks the MAC address and the creation time, which is how the Melissa virus author was identified in 1999. v6 reorders the same fields so they sort correctly; both are largely superseded by v7.

v4 — random, and v5 — hashed

v4 fills 122 bits from a cryptographically secure random source. No structure, no information leak, no ordering.

v5 hashes a namespace UUID plus a name with SHA-1 and takes 122 bits of the digest. Deterministic: the same input always gives the same UUID. v3 is the same with MD5.

v7 — timestamp then random

48 bits of Unix milliseconds followed by 74 random bits. Sortable by creation time while remaining generated locally, which is why it has become the default for database primary keys.

v8 is deliberately unspecified — a slot for custom layouts that still carry correct version and variant bits, for cases where you want your own structure without pretending it is a standard version.

Frequently asked questions

How do I tell which version a UUID is?

Read the first character of the third group — it is the version digit.

Which version should I use?

v7 for database keys, v4 for public identifiers where creation time should stay private, v5 when the id must be derived from a string.

Does v1 still leak a MAC address?

Yes, unless the implementation substitutes a random node id. Prefer v7.

Ready to try it?

Open the free browser-based UUID generator and apply what you just read — no sign-up, runs locally.

Open the UUID generator tool