Definition
The version of a UUID is a 4-bit field at bits 76–79 of the 128-bit value. In the standard hyphenated UUID string xxxxxxxx-xxxx-Vxxx-xxxx-xxxxxxxxxxxx, it is the first character of the third group — position 14 of the 36-character string, or position 13 if 0-indexed.
The version tells any consumer what algorithm generated the UUID and therefore how to interpret the other bits.
Version Values Defined by RFC 9562
RFC 9562 (published May 2024, superseding RFC 4122) defines eight UUID versions:
| Version | Hex digit | Algorithm | Status |
|---|---|---|---|
| 1 | 1 | Time + MAC address (100ns Gregorian timestamp) | Deprecated |
| 2 | 2 | DCE Security (POSIX UID/GID embedded) | Deprecated |
| 3 | 3 | Name-based, MD5 hash | Use v5 instead |
| 4 | 4 | Random (122 bits CSPRNG) | Current — use for tokens, external IDs |
| 5 | 5 | Name-based, SHA-1 hash | Current — deterministic IDs |
| 6 | 6 | Reordered timestamp (v1-compatible, sortable) | Current — v1 migration path |
| 7 | 7 | Unix millisecond timestamp + random | Recommended for primary keys |
| 8 | 8 | Custom/application-defined layout | Current — for custom formats |
Reading the Version
const uuid = '018fbe3a-4c5d-7b12-8abc-0123456789ab';
const version = parseInt(uuid[14], 16); // position 14 (0-indexed: 13)
console.log(version); // 7
import uuid
u = uuid.UUID('018fbe3a-4c5d-7b12-8abc-0123456789ab')
print(u.version) # 7
import "github.com/google/uuid"
u := uuid.MustParse("018fbe3a-4c5d-7b12-8abc-0123456789ab")
fmt.Println(u.Version()) // 7
Version vs Variant
The version field is often confused with the variant field. They are different:
- Version (bits 76–79): identifies the UUID’s generation algorithm
- Variant (bits 64–65): identifies the UUID’s byte layout specification
All RFC 9562 UUIDs have variant 10 (the RFC 4122 variant). The version can be 1–8. A UUID validator checks both fields — a well-formed v7 UUID must have 7 at the version position and 8, 9, a, or b at the variant position (position 17 of the string).
Special Cases: Nil and Max UUIDs
The nil UUID (00000000-0000-0000-0000-000000000000) and max UUID (ffffffff-ffff-ffff-ffff-ffffffffffff) are special sentinel values with no version field. The nil UUID represents “no identifier assigned”; the max UUID represents the maximum possible value. Both are defined in RFC 9562 §5.9.
Related Terms
- Variant — the companion field that identifies the layout specification
- Entropy — the random bits in v4 and v7
- Monotonic Counter — used by v7 generators for within-millisecond ordering
- UUID — the full format and structure
Frequently asked questions
Where is the version field in a UUID string?
The version is the single hex digit at position 13 (0-indexed) of the standard UUID string — the first character of the third hyphen-separated group: xxxxxxxx-xxxx-Vxxx-xxxx-xxxxxxxxxxxx. A UUID v7 always has 7 at that position; UUID v4 always has 4. See RFC 9562 §4.
Should I use v4 or v7?
Use v7 for database primary keys (time-sortable, index-friendly) and v4 for anything where creation order could leak information, like tokens or share links.
What did RFC 9562 add to the UUID standard?
RFC 9562, published in May 2024, adds UUID v6 (reordered timestamp for sortability), v7 (Unix millisecond timestamp), and v8 (custom layout). It also defines the Max UUID sentinel (all-ones complement of the Nil UUID) and deprecates v1 and v2. The existing format and v3, v4, v5 semantics are unchanged.
Where is the version field in a UUID?
The version is the single hex digit at position 13 of the standard hyphenated UUID string (0-indexed): xxxxxxxx-xxxx-Vxxx-xxxx-xxxxxxxxxxxx. It is also bits 76–79 of the 128-bit UUID value. A version 4 UUID always has a 4 at position 13; a version 7 UUID always has a 7. See RFC 9562 §4 for the full field layout.
Can I change the version of an existing UUID?
Technically yes — the version field is just 4 bits. But doing so is meaningless and dangerous: changing the version nibble does not change the other bits, so the result would be a structurally inconsistent UUID (e.g., a UUID with version 7 but no timestamp in the high bits). Never modify the version field of a generated UUID.