Vaultools
Menu

UUID (Universally Unique Identifier)

A UUID is a 128-bit identifier written as 32 hexadecimal digits in an 8-4-4-4-12 pattern, designed so that values can be generated independently anywhere with a negligible chance of collision. The current specification is RFC 9562.

Anatomy

A UUID is 16 bytes, normally shown as lowercase hex with hyphens:

f47ac10b-58cc-4372-a567-0e02b2c3d479
              ^    ^
              |    variant (8, 9, a or b)
              version (here 4)

The first digit of the third group is the version, and the first digit of the fourth group encodes the variant. In a version 4 UUID, 6 of the 128 bits are fixed for those two fields and the remaining 122 bits are random.

Versions you will meet

VersionHow it is made
v1A timestamp plus a clock sequence and a node identifier (historically a MAC address)
v3 / v5A hash of a namespace and a name: MD5 for v3, SHA-1 for v5. The same input always gives the same UUID
v4Random. By far the most common
v7A 48-bit Unix millisecond timestamp followed by random bits, so values sort by creation time

RFC 9562 also defines v6 (a reordered v1) and v8 (application-defined), plus the special all-zero “nil” and all-ones “max” values.

How unique is “unique”?

With 122 random bits, you would need to generate roughly 2.7 quintillion (2.7 × 10¹⁸) v4 UUIDs before the chance of even one collision reaches 50%. In practice collisions come from bad random number generators or copied data, not from bad luck.

Common pitfalls

References

Ads on this page

Non-personalized ads help keep Vaultools free — Google decides where they appear on the page.

Go Pro to remove them →