How long is a UUID?
A UUID is 36 characters as a canonical string — 32 hexadecimal digits plus 4 hyphens — encoding exactly 128 bits (16 bytes) of data. Every version, v1 through v8, has the same length.
By the Withuse team · Updated
The 8-4-4-4-12 structure
Two positions carry metadata in every RFC 9562 UUID: the version digit (first hex digit of the third group — 4 for random v4, 7 for time-ordered v7) and the variant digit (first of the fourth group; 8, 9, a or b marks a standard UUID). The remaining digits are payload — random bits, timestamps, or hashes depending on the version.
All the lengths you'll meet
| Form | Example | Length |
|---|---|---|
| Canonical string | 550e8400-e29b-41d4-a716-446655440000 | 36 chars |
| Without hyphens (hex) | 550e8400e29b41d4a716446655440000 | 32 chars |
| Braced (GUID style) | {550e8400-e29b-41d4-a716-446655440000} | 38 chars |
| URN form | urn:uuid:550e8400-… | 45 chars |
| Raw binary | — | 16 bytes / 128 bits |
Storage size by database
| Database | Recommended type | Bytes per value |
|---|---|---|
| PostgreSQL | uuid (guide) | 16 |
| MySQL / MariaDB | BINARY(16) | 16 |
| SQL Server | UNIQUEIDENTIFIER | 16 |
| SQLite | BLOB (16) or TEXT (36) | 16 / 36 |
| Any DB, text column | CHAR(36) | ~36–37 |
Rule of thumb: store 16 bytes, display 36 characters. Text storage more than doubles the footprint and makes every index comparison a string comparison.
Frequently asked questions
Is a UUID 32 or 36 characters?
Both numbers are correct; they describe different formattings of one value. The canonical string form defined by RFC 9562 is 36 characters: 32 hexadecimal digits arranged in groups of 8-4-4-4-12, plus the 4 hyphens that separate them. Strip the hyphens and you have the 32-character hex form, which many APIs and URL schemes prefer because it avoids a punctuation character. Wrap the canonical form in braces, as Microsoft tooling often does, and it becomes 38. Prefix it with urn:uuid: and it becomes 45. None of these change the identifier: underneath every representation sits the same 128 bits, which is 16 bytes, and that is the number that matters when you are choosing a column type or measuring storage.
Are UUIDs always the same length?
Yes. Every UUID is exactly 128 bits regardless of version, and the canonical text form is always 36 characters. Version 1, 4, 5, 7 and even the special NIL UUID of all zeros and MAX UUID of all ones occupy identical space. What differs between versions is the meaning of the bits, not how many there are: v4 spends 122 of them on randomness, v7 spends the first 48 on a millisecond timestamp and the rest on randomness, and v5 fills them with a truncated SHA-1 digest. Six bits are reserved in every version to mark the version and variant, which is why no version has the full 128 bits available for payload.
What column size should I use to store a UUID?
Prefer a native 16-byte binary type wherever one exists: uuid in PostgreSQL, UNIQUEIDENTIFIER in SQL Server, BINARY(16) in MySQL and MariaDB, and BLOB or a 16-byte column in SQLite. Storing the text form instead costs roughly 36 to 37 bytes per value, more than double, and that penalty repeats inside every index containing the column. Text storage also removes validation, so a malformed string can enter the table unnoticed, and it turns every comparison into a character-by-character operation rather than an integer one. If you truly must store text — a legacy schema you cannot change, for instance — use CHAR(36) rather than VARCHAR to avoid the extra length header.
Which character of a UUID tells the version?
The first hexadecimal digit of the third group, which is character 15 of the 36-character string: in xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx the 4 marks a version 4 UUID, and a 7 in that position marks version 7. The variant sits immediately after, as the first digit of the fourth group, and for standard RFC 9562 UUIDs it is 8, 9, a or b. Together these two positions are why a shape-only regular expression is not a real validator: a string can match the 8-4-4-4-12 pattern while carrying a version digit no specification uses. The NIL UUID is the notable exception, since its all-zero value has 0 in both positions and strict patterns reject it.
See the structure live — generate UUIDs with or without hyphens, braced, or uppercase in our free UUID generator.