Skip to content

How UUIDs work

Published 2 min read

A UUID (Universally Unique Identifier) is a 128-bit identifier used to uniquely identify resources across distributed systems.

UUID Structure

UUIDs are represented as 32 hexadecimal digits in five hyphen-separated groups following the 8-4-4-4-12 format, totaling 36 characters.

Version: v4
Variant: RFC 9562
Info: Uses cryptographically secure random numbers.

UUID Structure

367d5d9c
-
e5a7
-
4f3e
-
b289
-
1db715d6084e
Time Low

32 bits: Low field of the timestamp

3    6    7    d    5    d    9    c
0011 0110 0111 1101 0101 1101 1001 1100
Time Mid

16 bits: Middle field of the timestamp

e    5    a    7
1110 0101 1010 0111
Time High & Version

16 bits: 4 bits version + 12 bits high field of timestamp

4    f    3    e
0100 1111 0011 1110
Clock Sequence

16 bits: 2 bits variant + 14 bits clock sequence to help avoid duplicates

b    2    8    9
1011 0010 1000 1001
Node

48 bits: Node identifier

1    d    b    7    1    5    d    6    0    8    4    e
0001 1101 1011 0111 0001 0101 1101 0110 0000 1000 0100 1110

Example UUID

550e8400-e29b-41d4-a716-446655440000
              ↑    ↑
              │    └─ Variant bits (first 2 bits of clock sequence)
              └────── Version (first 4 bits of time high)

Breaking it down:

Understanding Variant Bits

The variant uses the first 2 bits (MSB0, MSB1) of the clock sequence field:

BitsHexVariantDescription
0xxx0-7NCS ReservedNetwork Computing System (NCS) backward compatibility, includes Nil UUID
10xx8-9, A-BRFC 9562The variant specified in this document (most common)
110xC-DMicrosoft ReservedMicrosoft Corporation backward compatibility
111xE-FFuture ReservedReserved for future definition, includes Max UUID

UUID Versions

At a Glance

VersionTime-OrderedDeterministicPrivacy-SafeDB PerformanceRecommendation
4Default choice
5✓ SHA-1Name mapping
6✓ Gregorian (1582)✗ MAC addressv1 migration
7✓ Unix (1970)⚠ Timing exposure✓✓Recommended if timing exposure is acceptable
8Implementation dependentCustom use
Legacy versions
1✓ Gregorian (1582)✗ MAC addressLegacy (use v6)
2Legacy DCE
3✓ MD5Legacy (use v5)

Legend: ✓ = Yes | ✗ = No | ⚠ = Depends/Varies

Time-Based Versions

v1 - Original time-based UUID

v6 - Improved time-based UUID

v7 - Modern time-based UUID

Random Version

v4 - Random UUID

Name-Based Versions

v3 - MD5 name-based

v5 - SHA-1 name-based

v8 - Custom name-based

Legacy Versions

v2 - DCE Security

Technical Specifications

VersionTimestampAlgorithmRandom Bits
160b (100ns, 1582)Timestamp + MAC0
2DCE Security
3MD5(namespace + name)0
4CSPRNG122
5SHA-1(namespace + name)0
660b (100ns, 1582)Timestamp + MAC (reordered)0
748b Unix (ms, 1970)Timestamp + random74
8CustomImplementation-defined0–122

References