Skip to content
SimpleTools24

UUID Format Explained: The 8-4-4-4-12 Structure

By SimpleTools24Published 3 min read

A UUID is 128 bits written as 32 hexadecimal digits in five groups separated by hyphens: 8-4-4-4-12, for example f81d4fae-7dec-11d0-a765-00a0c91e6bf6. That's 36 characters in total. Two positions carry fixed meaning: the 13th hex digit is the version (1–8), and the 17th hex digit encodes the variant, which is 8, 9, a or b for standard UUIDs. Everything else depends on the version: timestamps, random bits, hashes or node identifiers.

The Five Groups

text
f81d4fae - 7dec - 11d0 - a765 - 00a0c91e6bf6
   8        4      4      4         12        hex digits
  32       16     16     16         48        bits

The groups originally matched fields of the version 1 layout (time_low, time_mid, time_hi_and_version, clock_seq, node). In newer versions the field meanings differ, but the text layout stays the same for every UUID.

The Version Digit

The first hex digit of the third group is the version:

UUID versions and how they're generated
VersionDigitHow it's generated
11Gregorian timestamp + clock sequence + node
22DCE security (rarely used)
33MD5 hash of a namespace and name
44Random
55SHA-1 hash of a namespace and name
66Reordered v1 timestamp, sortable
77Unix millisecond timestamp + random
88Custom, vendor-defined layout

In f81d4fae-7dec-11d0-a765-00a0c91e6bf6, the third group is 11d0, so it's version 1. How to tell a UUID's version walks through more examples, and UUID versions explained covers each one.

The Variant Digit

The first hex digit of the fourth group holds the variant in its top bits:

  • 0–7: NCS backward-compatibility variant (legacy)
  • 8, 9, a, b: the standard RFC 9562 variant
  • c, d: Microsoft's legacy variant
  • e, f: reserved for the future

Almost every UUID you'll see uses the standard variant, so the 17th character is 8, 9, a or b. In the example, the fourth group is a765: standard variant.

Case and the Canonical Form

RFC 9562 allows upper, lower or mixed case hex digits when reading UUIDs, and recommends lowercase when generating them. The canonical form is lowercase with hyphens:

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

Normalising to this form before storing or comparing avoids treating the same ID as two different values.

Other Text Forms You'll Meet

Common UUID text forms
FormExampleWhere you see it
Standardf81d4fae-7dec-11d0-a765-00a0c91e6bf6Everywhere
UppercaseF81D4FAE-7DEC-11D0-A765-00A0C91E6BF6Windows tools, SQL Server
Braced{f81d4fae-7dec-11d0-a765-00a0c91e6bf6}Registry, COM, .NET "B" format
Compactf81d4fae7dec11d0a76500a0c91e6bf6URLs, some databases, .NET "N"
URNurn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6XML and RDF identifiers

All represent the same 128 bits. Removing hyphens or adding braces changes the text, not the value.

Binary Form

Stored natively, a UUID is 16 bytes. The standard byte order follows the text left to right (big-endian). Microsoft's GUID structure stores the first three groups little-endian in memory, which is why byte-level conversions between .NET and other systems sometimes scramble the first half of the value. Native database types (uuid in PostgreSQL, uniqueidentifier in SQL Server) handle this for you; trouble starts when code converts to raw bytes manually.

Special Values

Two UUIDs fall outside the version rules: the nil UUID (all zeros) and the max UUID (all f). Nil UUID and max UUID explains what they're used for.

Checking a UUID's Format

The UUID validator accepts standard, uppercase, braced, compact and URN forms, confirms each is a correctly formed 128-bit value, reports its variant and version, and shows the canonical form. It checks up to 1,000 lines at once. For time-based versions, the UUID decoder also shows the embedded timestamp. To validate in your own code, see UUID regex patterns.

Byte Layout for Each Version (Simplified)

What the 128 bits hold in common versions
VersionBits 0–47Bits 48–63Bits 64–127
v1time_low, time_midversion + time_highvariant + clock seq + node
v4randomversion + randomvariant + random
v5SHA-1 hash bitsversion + hashvariant + hash
v7Unix ms timestampversion + rand_avariant + rand_b

Bit positions count from the leftmost bit of the standard text form.

Formatting in Different Languages

  • JavaScript: id.toLowerCase(), and replaceAll('-', '') for compact form.
  • Python: str(u), u.hex, u.urn.
  • C#: g.ToString("D"), "N", "B".
  • SQL Server: CONVERT(char(36), @id) returns uppercase; wrap in LOWER() for canonical form.
  • PostgreSQL: id::text returns lowercase hyphenated form.

Frequently Asked Questions

How many characters is a UUID?

36 in the standard form (32 hex digits plus 4 hyphens), or 32 without hyphens.

Is a UUID case-sensitive?

No. Upper and lower case represent the same value; lowercase is canonical.

Which digit shows the UUID version?

The 13th hex digit, the first digit of the third group.

Can a UUID contain letters beyond f?

No. Only 0–9 and a–f are valid hexadecimal digits.

Summary

A UUID is 32 hex digits in 8-4-4-4-12 groups. The 13th digit is the version, the 17th encodes the variant, and lowercase with hyphens is the canonical form, whatever variations your systems accept.

Sources