Skip to main content

4. UUID Format

4. UUID Format

The UUID format is 16 octets (128 bits) in size; the variant bits in conjunction with the version bits described in the next sections determine finer structure. In terms of these UUID formats and layout, bit definitions start at 0 and end at 127, while octet definitions start at 0 and end at 15.

In the absence of explicit application or presentation protocol specification to the contrary, each field is encoded with the most significant byte first (known as "network byte order").

Saving UUIDs to binary format is done by sequencing all fields in big-endian format. However, there is a known caveat that Microsoft's Component Object Model (COM) GUIDs leverage little-endian when saving GUIDs. The discussion of this (see [MS_COM_GUID]) is outside the scope of this specification.

UUIDs MAY be represented as binary data or integers. When in use with URNs or as text in applications, any given UUID should be represented by the "hex-and-dash" string format consisting of multiple groups of uppercase or lowercase alphanumeric hexadecimal characters separated by single dashes/hyphens. When used with databases, please refer to Section 6.13.

The formal definition of the UUID string representation is provided by the following ABNF [RFC5234]:

UUID     = 4hexOctet "-"
2hexOctet "-"
2hexOctet "-"
2hexOctet "-"
6hexOctet
hexOctet = HEXDIG HEXDIG
DIGIT = %x30-39
HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"

Note that the alphabetic characters may be all uppercase, all lowercase, or mixed case, as per Section 2.3 of [RFC5234]. An example UUID using this textual representation from the above ABNF is shown in Figure 1.

f81d4fae-7dec-11d0-a765-00a0c91e6bf6

Figure 1: Example String UUID Format

The same UUID from Figure 1 is represented in binary (Figure 2), as an unsigned integer (Figure 3), and as a URN (Figure 4) defined by [RFC8141].

111110000001110101001111101011100111110111101100000100011101000
01010011101100101000000001010000011001001000111100110101111110110

Figure 2: Example Binary UUID

329800735698586629295641978511506172918

Figure 3: Example Unsigned Integer UUID (Shown as a Decimal Number)

urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6

Figure 4: Example URN Namespace for UUID

There are many other ways to define a UUID format; some examples are detailed below. Please note that this is not an exhaustive list and is only provided for informational purposes.

  • Some UUID implementations, such as those found in [Python] and [Microsoft], will output UUID with the string format, including dashes, enclosed in curly braces.
  • [X667] provides UUID format definitions for use of UUID with an OID.
  • [IBM_NCS] is a legacy implementation that produces a unique UUID format compatible with Variant 0xx of Table 1.

4.1. Variant Field

The variant field determines the layout of the UUID. That is, the interpretation of all other bits in the UUID depends on the setting of the bits in the variant field. As such, it could more accurately be called a "type" field; we retain the original term for compatibility. The variant field consists of a variable number of the most significant bits of octet 8 of the UUID.

Table 1 lists the contents of the variant field, where the letter "x" indicates a "don't-care" value.

MSB0MSB1MSB2MSB3VariantDescription
0xxx1-7Reserved. Network Computing System (NCS) backward compatibility, and includes Nil UUID as per Section 5.9.
10xx8-9,A-BThe variant specified in this document.
110xC-DReserved. Microsoft Corporation backward compatibility.
111xE-FReserved for future definition and includes Max UUID as per Section 5.10.

Table 1: UUID Variants

Interoperability, in any form, with variants other than the one defined here is not guaranteed but is not likely to be an issue in practice.

Specifically for UUIDs in this document, bits 64 and 65 of the UUID (bits 0 and 1 of octet 8) MUST be set to 1 and 0 as specified in row 2 of Table 1. Accordingly, all bit and field layouts avoid the use of these bits.

4.2. Version Field

The version number is in the most significant 4 bits of octet 6 (bits 48 through 51 of the UUID).

Table 2 lists all of the versions for this UUID variant 10xx specified in this document.

MSB0MSB1MSB2MSB3VersionDescription
00000Unused.
00011The Gregorian time-based UUID specified in this document.
00102Reserved for DCE Security version, with embedded POSIX UUIDs.
00113The name-based version specified in this document that uses MD5 hashing.
01004The randomly or pseudorandomly generated version specified in this document.
01015The name-based version specified in this document that uses SHA-1 hashing.
01106Reordered Gregorian time-based UUID specified in this document.
01117Unix Epoch time-based UUID specified in this document.
10008Reserved for custom UUID formats specified in this document.
10019Reserved for future definition.
101010Reserved for future definition.
101111Reserved for future definition.
110012Reserved for future definition.
110113Reserved for future definition.
111014Reserved for future definition.
111115Reserved for future definition.

Table 2: UUID Variant 10xx Versions Defined by This Specification

An example version/variant layout for UUIDv4 follows the table where "M" represents the version placement for the hexadecimal representation of 0x4 (0b0100) and the "N" represents the variant placement for one of the four possible hexadecimal representation of variant 10xx: 0x8 (0b1000), 0x9 (0b1001), 0xA (0b1010), 0xB (0b1011).

00000000-0000-4000-8000-000000000000
00000000-0000-4000-9000-000000000000
00000000-0000-4000-A000-000000000000
00000000-0000-4000-B000-000000000000
xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx

Figure 5: UUIDv4 Variant Examples

It should be noted that the other remaining UUID variants found in Table 1 leverage different sub-typing or versioning mechanisms. The recording and definition of the remaining UUID variant and sub-typing combinations are outside of the scope of this document.