By Docify

UUID Versions Explained: v4 vs v1, v5, v7 and v8 (Format & Length)

• 6 min read

A UUID is 128 bits written as 8-4-4-4-12 hex. RFC 9562 (May 2024, obsoletes RFC 4122) puts the version in the first nibble of the third group and the variant in the first bits of the fourth. Version 4 fills 122 bits from a CSPRNG via crypto.randomUUID(). Version 7 embeds a 48-bit Unix millisecond timestamp for time-ordered keys. Version 5 hashes a namespace plus name with SHA-1. Docify offers generators for v4, v7, v5, and ULID. All processing runs locally in your browser.

The same 36-character shape is not one algorithm. The version nibble says whether the remaining bits are random, a clock, or a name hash. The live UUID v4 generator calls crypto.randomUUID(). The live UUID v7 generator writes RFC 9562 §5.7 with Date.now() and crypto.getRandomValues(). The live ULID generator writes 26 Crockford Base32 characters (48-bit Unix ms plus 80 CSPRNG bits). The live UUID v5 generator writes RFC 9562 §5.5 with SHA-1 of a namespace UUID plus a UTF-8 name. Example output is DNS www.example.com → 2ed6657d-e927-568b-95e1-2665a8aea6a2. Those pages do not mint v1 or v3. You can generate 1 to 100 IDs at a time on v4, v7, and ULID pages.

UUID v4 format and length (36 characters, 128 bits)

Every UUID is 128 bits, written as 32 hexadecimal digits in the familiar 8-4-4-4-12 pattern with hyphens: xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx. With hyphens the string is 36 characters; without hyphens it is 32 characters.

The M position (first digit of the third group, or 13th hex digit) holds the version nibble. For UUID v4, this is always 4. The N position (first digit of the fourth group, or 17th hex digit) encodes the variant. RFC 4122/9562 UUIDs use variant 10xx, making that digit one of 8, 9, a, or b.

550e8400-e29b-41d4-a716-446655440000

In this example the 4 marks version 4 (random), and the a confirms the RFC 4122 variant. The remaining 122 bits are filled with cryptographically random data.

Shared layout, different payload

Version M and variant N

RFC 9562 §4 writes every UUID as five hex groups. The first digit of the third group is the 4-bit version. The first two bits of the fourth group are the variant; variant 10 makes that digit 8, 9, a, or b. Changing case or stripping hyphens does not change those bits.

919108f7-52d1-4320-9bac-f847db4148a8

That string is RFC 9562 Appendix A.3’s UUIDv4 example: the 4 in 4320 is the version; the 9 in 9bac is a legal variant-10xx nibble.

Random vs clock vs name

v4: 122 random bits

RFC 9562 §5.4 fills random_a, random_b, and random_c (122 bits) from a random or pseudorandom source, then overwrites the version (4) and variant (10). WHATWG crypto.randomUUID() is specified as that version 4 UUID. Successive values are not time-ordered. Section 1 of the RFC notes the B-tree locality cost of inserting them as primary keys. They still are not secrets and are not checked against a registry here.

v1 and v6: Gregorian 100-nanosecond time

UUIDv1 (§5.1) stores a 60-bit count of 100-nanosecond intervals since 00:00:00.00, 15 October 1582 UTC, plus a 14-bit clock sequence and a 48-bit node field (often a MAC). The timestamp is split low / mid / high, so a lexical sort of the 36-character string is not chronological. UUIDv6 (§5.6) uses the same clock but stores the 48 most significant time bits first so the string sorts with time. The RFC says systems without a v1 legacy should use v7 instead. A node field that is a MAC can identify a machine; this page never reads a MAC.

v7: Unix milliseconds in the high bits

UUIDv7 (§5.7) puts a 48-bit Unix epoch timestamp in milliseconds (since 1970-01-01T00:00:00Z, leap seconds excluded) in bits 0–47, then version 7, then 74 remaining bits that are random or an optional monotonic counter. Implementations SHOULD use v7 instead of v1 or v6 when they want a time-ordered UUID. The v7 generator mints that layout. It does not implement §6.2 monotonic counters and does not extract a clock from a pasted string.

v3 and v5: namespace plus name

Both versions hash a 16-octet Namespace ID concatenated with a name (§6.5). v3 uses MD5 (§5.3); v5 uses SHA-1 and keeps the leftmost 128 bits of the 160-bit digest, discarding the rest (§5.5). The version and variant bits then overwrite the matching hash bits. The same namespace and name always yield the same UUID. The RFC prefers v5 over v3. A SHA-256 name-based ID MUST be UUIDv8, not v5. The v5 generator assembles that SHA-1 layout. The sample generates output is DNS www.example.com → 2ed6657d-e927-568b-95e1-2665a8aea6a2 (RFC 9562 Appendix A.4). Name bytes are UTF-8 of the typed string, not DNS wire format. Docify’s hash generator can SHA-1 the name alone and does not assemble a UUID. v3 (MD5) is still not minted.

UUID v8 (custom)

UUID v8 (RFC 9562 §5.8) reserves 122 bits for implementation-defined layouts. The version nibble is 8, and the variant bits follow the standard 10xx pattern, but everything else is up to you.

Some organizations use v8 to embed custom timestamps, shard IDs, or other domain-specific data. The RFC explicitly notes that v8 is not a replacement for filling those bits with v4 random data — if you just need a random ID, use v4. If you need time-ordering, use v7.

Because v8 layouts are implementation-specific, this site does not generate them. The UUID v4 generator and UUID v7 generator cover the most common use cases.

Which UUID version should you use?

For most applications, UUID v4 is the right choice — it is simple, widely supported, and has negligible collision probability with 122 random bits. If you need time-ordered IDs for database primary keys, UUID v7 preserves insertion order and improves index locality. Use v5 when you need deterministic IDs derived from a namespace and name. The other versions are legacy (v1, v6) or special-purpose (v2, v3, v8).

VersionBased onLengthBest for
v1Timestamp + MAC address36 / 32 charsLegacy systems
v3MD5 hash of namespace + name36 / 32 charsDeterministic IDs (prefer v5)
v4122 random bits36 / 32 charsGeneral-purpose unique IDs
v5SHA-1 hash of namespace + name36 / 32 charsDeterministic IDs from names
v6Reordered v1 timestamp36 / 32 charsSortable v1 replacement
v7Unix ms timestamp + random36 / 32 charsDatabase keys (time-ordered)
v8Custom (122 bits user-defined)36 / 32 charsImplementation-specific layouts

All versions are 128 bits (16 bytes). With hyphens: 36 characters. Without hyphens: 32 characters.

Generate RFC version 4 UUIDs

Count returns 1–100. Click Generate to run. crypto.randomUUID() in the browser. Not v1 or v3. Version 5 and version 7 are separate pages. Nothing is uploaded.

Use UUID Generator →

FAQ

What is the difference between UUID versions?
v1 uses timestamp + MAC. v4 is random. v5 uses namespace + name hash. v7 uses timestamp + random.
Which version should I use?
v4 (random) is the most common choice. v7 is good when you need time-ordered IDs.
Are UUIDs globally unique?
v4 has 122 random bits, making collisions extremely unlikely. Not guaranteed but practical.
Does this tool upload my data?
No. All generation runs in your browser using crypto.randomUUID() or equivalent.

Related