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
| Bits | Hex positions | Field name | Description |
|---|---|---|---|
| 0–31 | Group 1 (chars 1–8) | time_low / rand | Version-specific |
| 32–47 | Group 2 (chars 10–13) | time_mid / rand | Version-specific |
| 48–51 | Group 3, char 15 | version | 4-bit version nibble |
| 52–63 | Group 3, chars 16–18 | time_hi / rand_a | Version-specific |
| 64–65 | Group 4, char 20 (top 2 bits) | variant | Always 10 (binary) |
| 66–79 | Group 4, chars 20–23 (remaining) | clock_seq / rand | Version-specific |
| 80–127 | Group 5 (chars 25–36) | node / rand_b | Version-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 value | UUID version | Description |
|---|---|---|
1 | v1 | Gregorian time + MAC address |
2 | v2 | DCE Security (rarely used) |
3 | v3 | MD5 name-based (deprecated) |
4 | v4 | Random |
5 | v5 | SHA-1 name-based |
6 | v6 | Reordered time + MAC address |
7 | v7 | Unix millisecond time + random |
8 | v8 | Application-defined |
Variant field values
The first hex character of group 4 encodes the variant in its top 2 bits:
| Hex range | Variant | Description |
|---|---|---|
0–7 (0000–0111) | NCS | Legacy compatibility |
8–b (1000–1011) | RFC 9562 | All modern UUIDs |
c–d (1100–1101) | Microsoft | Windows GUID format |
e–f (1110–1111) | Reserved | Not 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.
Related terms
- Version — UUID version field
- Variant — UUID variant field
- Random Bits — UUID entropy
- Monotonic Counter — within-ms UUID ordering
- UUID Byte Layout — visual bit map
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.