If you are configuring a database column, designing an API schema, or validating input in your code, you probably need a quick, definitive answer to the question: How long is a UUID?
Here is the direct answer:
- In standard text format: A UUID is 36 characters long (consisting of 32 hexadecimal characters and 4 hyphens).
- Without hyphens: A UUID is 32 characters long.
- In binary hardware storage: A UUID contains 128 bits, which equals exactly 16 bytes.
┌────────────────────────────────────────────────────────────────────────┐
│ THE ANATOMY OF UUID LENGTH │
├────────────────────────────────────────────────────────────────────────┤
│ Canonical String: 550e8400-e29b-41d4-a716-446655440000 (36 Characters) │
│ Compact String: 550e8400e29b41d4a716446655440000 (32 Characters) │
│ Binary Storage: [ 16 Raw Binary Bytes ] (128 Bits) │
└────────────────────────────────────────────────────────────────────────┘
Understanding the difference between the visual textual representation (36 characters) and the underlying binary data (128 bits / 16 bytes) is one of the most important concepts in database optimization, API design, and systems programming.
In this comprehensive guide, we will break down UUID length across every dimension: characters, hexadecimal digits, hyphens, bits, bytes, database storage, and alternative encodings under the modern RFC 9562 standard.
1. How Long Is a UUID? (Quick Breakdown)
To see why a UUID has different measurements depending on context, let’s examine a canonical UUID example:
550e8400-e29b-41d4-a716-446655440000
If you count every character in that string from left to right:
- 32 Hexadecimal Digits:
5,5,0,e,8,4,0,0,e,2,9,b… - 4 Hyphens:
-,-,-,- - Total String Length: $32 + 4 = \mathbf{36 \text{ characters}}$
At the hardware level, computers do not store the characters or hyphens. They store the raw binary value:
- Total Bits: 128 bits
- Total Bytes: $\frac{128}{8} = \mathbf{16 \text{ bytes}}$
If you need to generate a fresh, properly formatted 36-character identifier right now, use our free UUID Generator.
2. Why Is a UUID 36 Characters Long?
Why did computer scientists choose 36 characters instead of 20, 30, or 40?
The 36-character length is a direct mathematical result of converting 128 binary bits into human-readable hexadecimal notation (Base-16), separated by four formatting hyphens.
Step 1: 128 Bits of Binary Data
0101010100001110... (128 ones and zeros)
Step 2: Convert to Hexadecimal (1 Hex Digit = 4 Bits)
128 bits ÷ 4 bits per digit = 32 Hexadecimal Digits
Step 3: Group into the Standard 8-4-4-4-12 Layout
550e8400 - e29b - 41d4 - a716 - 446655440000
Step 4: Add 4 Hyphen Separators
32 Hex Digits + 4 Hyphens = 36 Total Characters
The Math Behind the Conversion
| Metric | Calculation | Result |
|---|---|---|
| Total Binary Size | Fundamental UUID specification | 128 bits |
| Byte Size | $128 \text{ bits} \div 8 \text{ bits per byte}$ | 16 bytes |
| Hexadecimal Digits | $128 \text{ bits} \div 4 \text{ bits per hex digit}$ | 32 hex characters |
| Hyphen Separators | Standard RFC 9562 textual layout | 4 hyphens |
| Canonical String Length | $32 \text{ hex digits} + 4 \text{ hyphens}$ | 36 characters |
3. How Many Bits Are in a UUID?
Every standard UUID contains exactly 128 bits.
A “bit” (binary digit) is the fundamental unit of computer data, holding either a 0 or a 1. A 128-bit identifier space provides:
$$2^{128} = 340,282,366,920,938,463,463,374,607,431,768,211,456 \approx 3.4 \times 10^{38} \text{ values}$$
This number space is so unimaginably vast that even if billions of systems generate millions of UUIDs every second, the probability of an accidental collision is virtually zero.
Important Nuance: Are All 128 Bits Random in UUID v4?
A common misconception is that a UUID Version 4 (Random) contains 128 bits of pure randomness.
In reality, under RFC 9562:
- 4 bits are reserved for the Version Field (set to binary
0100=4). - 2 bits are reserved for the Variant Field (set to binary
10). - 122 bits are generated from cryptographically secure random entropy.
Even with 122 random bits instead of 128, the number of possible UUID v4 combinations is $2^{122} \approx 5.3 \times 10^{36}$, providing total collision resistance for practical software engineering.
4. How Many Bytes Is a UUID?
A UUID contains exactly 16 bytes ($128 \text{ bits} \div 8 = 16 \text{ bytes}$).
┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 10│ 11│ 12│ 13│ 14│ 15│ 16│
└───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┴───┘
◄────────────────────── 16 Raw Binary Bytes ──────────────────────►
Binary Bytes vs. Text Characters: Why It Matters for Storage
There is a massive difference between storing a UUID in its native 16-byte binary format versus storing it as a 36-character text string:
- Native Binary Format: Requires 16 bytes of disk and RAM.
- ASCII / UTF-8 Text String (
CHAR(36)): Requires 36 bytes of disk and RAM (over 2.25x larger).
In a database table with 100 million rows and multiple indexed foreign keys, storing UUIDs as 36-character text strings wastes gigabytes of memory cache compared to native 16-byte storage.
5. Canonical UUID Character Breakdown (8-4-4-4-12)
In the standard textual representation, the 32 hexadecimal characters are divided into five distinct groups separated by hyphens:
550e8400 - e29b - 41d4 - a716 - 446655440000
[ Group 1 ] [Group 2] [Group 3] [Group 4] [ Group 5 ]
[ 8 chars ] [4 chars] [4 chars] [4 chars] [ 12 chars ]
[ 32 bits ] [16 bits] [16 bits] [16 bits] [ 48 bits ]
| Group | Hex Characters | Binary Bits | Byte Count | Structural Role |
|---|---|---|---|---|
| Group 1 | 8 chars | 32 bits | 4 bytes | Time-low / High-order random bits |
| Group 2 | 4 chars | 16 bits | 2 bytes | Time-mid / Mid-order random bits |
| Group 3 | 4 chars | 16 bits | 2 bytes | Contains 4-bit Version Field (Mxxx) |
| Group 4 | 4 chars | 16 bits | 2 bytes | Contains 2-bit Variant Field (Nxxx) |
| Group 5 | 12 chars | 48 bits | 6 bytes | Node ID / Low-order random payload |
| Hyphens | 4 chars | 0 bits | 0 bytes | Readability separators |
| Total | 36 chars | 128 bits | 16 bytes | Canonical RFC 9562 UUID |
You can inspect and confirm these character positions on any identifier using our free UUID / GUID Validator.
6. Are All UUIDs 36 Characters Long?
The phrase “a UUID is 36 characters long” specifically describes the canonical RFC textual representation. In software, UUIDs can be formatted in several alternative representations:
┌────────────────────────────────────────────────────────────────────────┐
│ COMMON TEXTUAL REPRESENTATIONS OF A UUID: │
├────────────────────────────────────────────────────────────────────────┤
│ 1. Canonical RFC String: 550e8400-e29b-41d4-a716-446655440000 (36 ch) │
│ 2. Compact (No Hyphens): 550e8400e29b41d4a716446655440000 (32 ch) │
│ 3. Microsoft Braced GUID: {550e8400-e29b-41d4-a716-446655440000} (38) │
│ 4. Parentheses Format: (550e8400-e29b-41d4-a716-446655440000) (38) │
│ 5. URN Namespace Format: urn:uuid:550e8400-e29b-41d4-a716... (45 ch) │
│ 6. Base64 URL Encoded: VQ6EAOKbQdSnFkRmVUQAAA (22 ch) │
└────────────────────────────────────────────────────────────────────────┘
1. Canonical RFC Format (36 Characters)
- Example:
550e8400-e29b-41d4-a716-446655440000 - Standard format used in REST APIs, JSON payloads, and PostgreSQL.
2. Compact Format Without Hyphens (32 Characters)
- Example:
550e8400e29b41d4a716446655440000 - Often used in MongoDB
_idstrings, compact file paths, or Redis keys.
3. Microsoft Windows / Braced GUID (38 Characters)
- Example:
{550e8400-e29b-41d4-a716-446655440000} - Common in C#, .NET, Windows Registry, and COM interfaces. Test custom formatting with our GUID Generator.
4. Base64 URL-Safe Encoded (22 Characters)
- Example:
VQ6EAOKbQdSnFkRmVUQAAA - By converting the raw 16 bytes into Base64, the string compresses to just 22 characters while preserving 100% of the 128-bit data. Try our Base64 UUID Generator.
Key Rule: Regardless of whether a UUID is displayed as 36 characters, 32 characters, 38 characters, or 22 characters, the underlying identifier is always 128 bits (16 bytes).
7. UUID v4 Length vs. UUID v7 Length
All standardized UUID versions (v1 through v8) share the exact same structural length:
- UUID v4 (Random): 36 characters / 128 bits / 16 bytes
- UUID v7 (Time-Ordered): 36 characters / 128 bits / 16 bytes
- UUID v1 / v6 (Time-Based): 36 characters / 128 bits / 16 bytes
- UUID v5 (SHA-1 Hash): 36 characters / 128 bits / 16 bytes
UUID v4: 550e8400-e29b-41d4-a716-446655440000 (36 Chars | 128 Bits)
UUID v7: 018d3b7d-3b7d-7bad-9bdd-2b0d7b3dcb6d (36 Chars | 128 Bits)
The difference between versions is how the 128 bits are calculated internally, not how many bits or characters exist. UUID v7 encodes a 48-bit Unix millisecond timestamp at the beginning to maintain sequential B-Tree database indexing, but its total length is identical to UUID v4.
8. UUID vs. GUID Length
Is a Microsoft GUID longer or shorter than a UUID?
They are the exact same size.
- UUID (Universally Unique Identifier) is the international IETF standard term.
- GUID (Globally Unique Identifier) is Microsoft’s terminology.
Both represent 128 bits (16 bytes) and render as 36 characters in standard hyphenated format (or 38 characters when wrapped in Windows {curly braces}).
9. UUID Length in Databases: Storage Considerations
When creating a database schema, how you define your UUID column directly impacts query speed and disk consumption:
-- Approach A: Stored as Text (Inefficient)
CREATE TABLE users_text (
id VARCHAR(36) PRIMARY KEY -- Uses 36 bytes per row + indexing overhead
);
-- Approach B: Stored as Native 16-Byte Binary (Recommended)
CREATE TABLE users_native (
id UUID PRIMARY KEY -- PostgreSQL native type: Uses exactly 16 bytes
);
Database Data Type Comparison:
| Database Engine | Recommended Data Type | Storage Size on Disk | Notes |
|---|---|---|---|
| PostgreSQL | UUID | 16 bytes | Native binary storage; automatically displays as 36-char string. |
| MySQL 8.0+ | BINARY(16) | 16 bytes | Recommended over VARCHAR(36) to prevent index bloat in InnoDB. |
| SQL Server | UNIQUEIDENTIFIER | 16 bytes | Native 16-byte GUID storage. |
| SQLite | BLOB or TEXT | 16 bytes (BLOB) / 36 bytes (TEXT) | Use BLOB for compact storage. |
10. UUID Length Compared to Other Identifier Types
| Identifier Type | Binary Size (Bits) | Storage Size (Bytes) | Canonical String Length | Example Format |
|---|---|---|---|---|
| Standard UUID (RFC 9562) | 128 bits | 16 bytes | 36 characters | 550e8400-e29b-41d4-a716-446655440000 |
| UUID (No Hyphens) | 128 bits | 16 bytes | 32 characters | 550e8400e29b41d4a716446655440000 |
| Microsoft GUID (Braced) | 128 bits | 16 bytes | 38 characters | {550e8400-e29b-41d4-a716-446655440000} |
| Base64 UUID | 128 bits | 16 bytes | 22 characters | VQ6EAOKbQdSnFkRmVUQAAA |
BIGINT Integer ID | 64 bits | 8 bytes | 1 to 20 digits | 184729104829104 |
Standard INT ID | 32 bits | 4 bytes | 1 to 10 digits | 4829104 |
11. Does a Longer String Mean More Uniqueness?
A common beginner question is: “Does a 36-character UUID with hyphens have more uniqueness than a 32-character UUID without hyphens?”
No.
Uniqueness is determined strictly by the 128 binary bits of entropy, not the text formatting.
- Adding hyphens (
-), curly braces ({}), or uppercase characters changes how the identifier is displayed on a screen, but the mathematical value remains identical. - Removing hyphens produces a 32-character string containing the exact same 128 bits of binary data.
If you need to batch-generate test identifiers for performance benchmarking across text and binary storage, check out our Bulk UUID Generator.
12. Frequently Asked Questions (FAQ)
How many characters is a standard UUID?
A standard canonical UUID is 36 characters long, consisting of 32 hexadecimal digits and 4 hyphen separators (8-4-4-4-12).
How many characters is a UUID without hyphens?
Without hyphens, a UUID is 32 hexadecimal characters long.
How many bits is a UUID?
A UUID contains exactly 128 bits.
How many bytes is a UUID?
A UUID contains exactly 16 bytes ($128 \div 8 = 16$).
Is UUID v4 also 36 characters long?
Yes. All standardized UUID versions (v1, v3, v4, v5, v6, v7, and v8) are 36 characters long in standard hyphenated format and represent 128 bits.
Is a GUID the same character length as a UUID?
Yes. A standard GUID is 36 characters long with hyphens. When formatted in Microsoft Windows style with enclosing curly braces, it is 38 characters long.
Should I store UUIDs in databases as CHAR(36) or BINARY(16)?
Whenever possible, store UUIDs in native binary types (such as UUID in PostgreSQL or BINARY(16) in MySQL). This cuts storage from 36 bytes down to 16 bytes per row and significantly improves B-Tree index memory efficiency.
Can the length of a UUID change?
No. Under official IETF RFC 9562 standards, the underlying binary length of a UUID is fixed at exactly 128 bits (16 bytes).
13. Conclusion & Developer Tools
To summarize:
- String Length with Hyphens: 36 characters
- String Length without Hyphens: 32 characters
- Binary Size: 128 bits (16 bytes)
Whether you need to generate, format, or validate unique identifiers for your applications, explore our full suite of free developer tools:
- UUID Generator — Create instant, cryptographically secure UUID v4 and v7 identifiers.
- GUID Generator — Generate Microsoft & .NET ready GUIDs.
- UUID / GUID Validator — Validate syntax, inspect version & extract timestamps.
- Bulk UUID Generator — Generate up to 10,000 identifiers in batch.
- Base64 UUID Generator — Convert 128-bit UUIDs into compact 22-character strings.