A UUID (universally unique identifier, also called GUID) is a 128-bit label written as 32 hex digits in the pattern 8-4-4-4-12. Anyone can generate one without a central registry. The format is defined by RFC 9562. Create them with the UUID Generator, read them with the UUID & ULID Decoder, and choose between the popular kinds in UUID v4 vs UUID v7 vs ULID. The glossary entry is UUID.
Reading a UUID
- Example:
f47ac10b-58cc-4372-a567-0e02b2c3d479. - The version is the first hex digit of the third group (
4here: random). - The variant is in the first digit of the fourth group:
8,9,aorbmeans the standard layout (herea). - Two special values exist: the nil UUID
00000000-0000-0000-0000-000000000000and the max UUIDffffffff-ffff-ffff-ffff-ffffffffffff.
The versions
| Version | What it contains | Notes |
|---|---|---|
| 1 | Timestamp (100 ns ticks since 1582-10-15) + node ID | Legacy; the node ID can leak a MAC address |
| 3 | MD5 hash of a namespace and a name | Same input, same UUID; avoid for new work |
| 4 | 122 random bits | The default; reveals nothing |
| 5 | SHA-1 hash of a namespace and a name | Same input, same UUID; stable IDs for names |
| 6 | v1 with the timestamp reordered so it sorts | Compatibility with v1 |
| 7 | 48-bit Unix time in ms + random | Sorts by creation time; good for database keys |
| 8 | Custom: vendor-defined layout | Experimental or private use |
How unlikely is a collision?
A version-4 UUID carries 122 random bits, about 5.3 × 10^36 values. By the birthday paradox, you would need roughly 2.7 × 10^18 UUIDs for a 50 % chance of a single duplicate: generating a billion a second, that takes about 86 years.
Practical advice
- Name-based UUIDs are reproducible: the version-5 UUID of
example.comin the DNS namespace is alwayscfbff0d1-9375-5685-968c-48ce8b15ae17. - A UUID is an identifier, not a secret. Do not use one as a password-reset token or API key unless it comes from a secure random source, and prefer longer tokens for secrets.
- Store UUIDs as 16 bytes (a native
uuidcolumn), not as 36-character text, when you can. - Use time-ordered v7 for new database primary keys to avoid scattering inserts across the index.