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.
In this guide
The Five Groups
f81d4fae - 7dec - 11d0 - a765 - 00a0c91e6bf6
8 4 4 4 12 hex digits
32 16 16 16 48 bitsThe 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:
| Version | Digit | How it's generated |
|---|---|---|
| 1 | 1 | Gregorian timestamp + clock sequence + node |
| 2 | 2 | DCE security (rarely used) |
| 3 | 3 | MD5 hash of a namespace and name |
| 4 | 4 | Random |
| 5 | 5 | SHA-1 hash of a namespace and name |
| 6 | 6 | Reordered v1 timestamp, sortable |
| 7 | 7 | Unix millisecond timestamp + random |
| 8 | 8 | Custom, 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 variantc,d: Microsoft's legacy variante,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:
f81d4fae-7dec-11d0-a765-00a0c91e6bf6Normalising to this form before storing or comparing avoids treating the same ID as two different values.
Other Text Forms You'll Meet
| Form | Example | Where you see it |
|---|---|---|
| Standard | f81d4fae-7dec-11d0-a765-00a0c91e6bf6 | Everywhere |
| Uppercase | F81D4FAE-7DEC-11D0-A765-00A0C91E6BF6 | Windows tools, SQL Server |
| Braced | {f81d4fae-7dec-11d0-a765-00a0c91e6bf6} | Registry, COM, .NET "B" format |
| Compact | f81d4fae7dec11d0a76500a0c91e6bf6 | URLs, some databases, .NET "N" |
| URN | urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6 | XML 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)
| Version | Bits 0–47 | Bits 48–63 | Bits 64–127 |
|---|---|---|---|
| v1 | time_low, time_mid | version + time_high | variant + clock seq + node |
| v4 | random | version + random | variant + random |
| v5 | SHA-1 hash bits | version + hash | variant + hash |
| v7 | Unix ms timestamp | version + rand_a | variant + rand_b |
Bit positions count from the leftmost bit of the standard text form.
Formatting in Different Languages
- JavaScript:
id.toLowerCase(), andreplaceAll('-', '')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 inLOWER()for canonical form. - PostgreSQL:
id::textreturns 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.
Related tools
Sources
- RFC 9562 – Universally Unique IDentifiers (UUIDs), Section 4 UUID Format – IETF (opens in a new tab)
Related articles
- UUID Regex PatternsTested regex patterns for UUIDs, from loose format checks to strict version and variant validation, with examples.
- How to Tell a UUID's VersionRead the version and variant digits by eye, with worked examples and code for checking them programmatically.
- Nil UUID and Max UUIDThe all-zero and all-f special UUIDs, how languages expose them, and why an unexpected nil UUID is usually a bug.