UUID structure overview

A UUID is represented as 32 hex characters in 5 groups separated by hyphens:

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
 8 chars  4    4    4    12 chars
 32 bits  16   16   16   48 bits

Total: 128 bits = 32 hex characters.

Bit positions

BitsHex positionsField nameDescription
0–31Group 1 (chars 1–8)time_low / randVersion-specific
32–47Group 2 (chars 10–13)time_mid / randVersion-specific
48–51Group 3, char 15version4-bit version nibble
52–63Group 3, chars 16–18time_hi / rand_aVersion-specific
64–65Group 4, char 20 (top 2 bits)variantAlways 10 (binary)
66–79Group 4, chars 20–23 (remaining)clock_seq / randVersion-specific
80–127Group 5 (chars 25–36)node / rand_bVersion-specific

Field layout by UUID version

UUID v1 (time-based, MAC address):
[32-bit time_low][16-bit time_mid][4-bit ver=1][12-bit time_hi][2-bit var][14-bit clock_seq][48-bit node/MAC]

UUID v4 (random):
[32-bit rand][16-bit rand][4-bit ver=4][12-bit rand][2-bit var][62-bit rand]

UUID v6 (reordered time, MAC address):
[48-bit time_high][4-bit ver=6][12-bit time_low][2-bit var][14-bit clock_seq][48-bit node]

UUID v7 (Unix timestamp + random):
[48-bit unix_ts_ms][4-bit ver=7][12-bit rand_a][2-bit var][62-bit rand_b]

UUID v8 (application-defined):
[32-bit custom_a][16-bit custom_b][4-bit ver=8][12-bit custom_c][2-bit var][62-bit custom_d]

Reading bit fields in code

function parseUuidFields(uuid: string) {
  const hex = uuid.replace(/-/g, '');

  return {
    // Version: first hex char of group 3 (char index 12)
    version: parseInt(hex[12], 16),

    // Variant: top 2 bits of group 4 (byte index 8)
    variantByte: parseInt(hex[16], 16),
    variant: parseInt(hex[16], 16) >> 2,  // top 2 bits: 10 = RFC 9562

    // UUID v7: 48-bit Unix ms timestamp from first 12 hex chars
    ...(parseInt(hex[12], 16) === 7 && {
      timestampMs: parseInt(hex.slice(0, 12), 16),
      createdAt: new Date(parseInt(hex.slice(0, 12), 16)).toISOString(),
    }),
  };
}

parseUuidFields('018fbe3a-4c5d-7b12-8f3e-1a2b3c4d5e6f');
// { version: 7, variantByte: 8, variant: 2, timestampMs: 1760558400000, createdAt: '...' }

Version nibble values

Hex valueUUID versionDescription
1v1Gregorian time + MAC address
2v2DCE Security (rarely used)
3v3MD5 name-based (deprecated)
4v4Random
5v5SHA-1 name-based
6v6Reordered time + MAC address
7v7Unix millisecond time + random
8v8Application-defined

Variant field values

The first hex character of group 4 encodes the variant in its top 2 bits:

Hex rangeVariantDescription
0–7 (0000–0111)NCSLegacy compatibility
8–b (1000–1011)RFC 9562All modern UUIDs
c–d (1100–1101)MicrosoftWindows GUID format
e–f (1110–1111)ReservedNot used

All UUIDs generated by standard libraries use variant 10 (bits 64–65), which displays as 8, 9, a, or b in the first character of the fourth UUID group.

Frequently asked questions

What are the fixed bits in every UUID?

Every RFC 9562 UUID has two fixed fields: the version nibble (4 bits at positions 48–51, the first hex digit of the third group) and the variant field (2 bits at positions 64–65, the first two bits of the fourth group). The version nibble values are 1–8; the variant bits are always 10 (binary) for RFC 9562 UUIDs, displayed as 8, 9, a, or b in the fourth group's first hex character. See Variant and Version.

How do I identify a UUID version from the string?

The version is the first hex character of the third group (after the second hyphen). In 018fbe3a-4c5d-7b12-8f3e-1a2b3c4d5e6f, the bold 7 indicates UUID v7. Values: 1=v1, 4=v4, 6=v6, 7=v7, 8=v8. The variant is the first hex character of the fourth group — must be 8, 9, a, or b for RFC 9562 UUIDs.

What is the difference between UUID v7 rand_a and rand_b fields?

In UUID v7, rand_a is 12 bits immediately following the version nibble (bits 52–63). It is often used as a per-millisecond monotonic counter (Method 1 in RFC 9562 §6.2) to prevent same-millisecond collisions. rand_b is 62 bits following the variant bits (bits 66–127) and is always purely random. See Random Bits — UUID entropy.