UUID meaning and definition

A UUID — Universally Unique Identifier — is a 128-bit number used to label something without asking anyone for permission first. Two machines with no network connection between them can each mint one, and the chance they produce the same value is small enough that production systems treat it as zero.

That is the whole point. A database sequence guarantees uniqueness by making every writer talk to one authority. A UUID trades that guarantee for independence: no coordination, no round trip, no single point of failure, and an identifier that can be created in a mobile app that has been offline for a week and still merge cleanly when it syncs.

The current specification is RFC 9562, published in 2024, which replaced the long-standing RFC 4122 and added the time-ordered versions 6, 7 and 8.

UUID format

A UUID is conventionally written as 32 hexadecimal digits in five hyphen-separated groups:

018f3c4e-7a21-7b3c-9d4e-5f6a7b8c9d0e
   8    -  4 -  4 -  4 -     12

The hyphens carry no information; they are there for human eyes. Two positions in that string do carry information:

Everything else is version-specific payload. That is why you can identify any UUID at a glance without parsing it: the 15th and 20th characters tell you what you are looking at.

The versions worth knowing

RFC 9562 defines eight, but only a few matter for new work:

VersionMethodSortableDeterministicUse today?
v1Timestamp + MAC addressYes (but byte order quirks)NoAvoid — superseded by v7
v3Name-based, MD5NoYesAvoid — use v5 instead
v4Random (CSPRNG)NoNoYes — default for opaque IDs
v5Name-based, SHA-1NoYesYes — stable ID from a name or URL
v6Reordered v1 timestampYesNoRarely — v7 is preferred
v7Timestamp + randomYesNoYes — default for database keys
v8Custom layoutDependsDependsOnly for specific application needs

If you are choosing between the two that people actually use, the UUID v4 vs UUID v7 comparison covers the decision in detail.

Is it really unique?

Not guaranteed — probabilistic. For a random v4, uniqueness rests on 122 bits of entropy, and the relevant maths is the birthday problem rather than the raw space: collisions become likely far sooner than exhausting all 2¹²² values, but “far sooner” here still means generating on the order of a quintillion identifiers before the probability becomes worth thinking about.

Two practical caveats matter more than the arithmetic:

What is a UUID used for?

They are a poor fit where a short, human-communicable code is needed — order numbers read over the phone, coupon codes — and where a plain integer would do, inside a single small table that nothing else references.

Common mistakes

Ready to make one? Generate a UUID v7 if it is going in a database, or generate a UUID v4 if it is going in a link.

Frequently asked questions

What does UUID stand for?

UUID stands for Universally Unique Identifier — a 128-bit number defined by RFC 9562 used to uniquely identify information across systems without requiring coordination.

What is a UUID used for?

UUIDs are used as database primary keys, distributed system identifiers, idempotency keys for API requests, event and trace IDs, and offline record creation — any situation where unique IDs must be generated without a central authority.

Is a UUID guaranteed to be unique?

Not mathematically guaranteed, but the collision probability is so small it's treated as unique in practice. You'd need to generate billions of v4 UUIDs before a collision became likely.

What's the difference between a UUID and a GUID?

None, in practice. GUID is Microsoft's name for the same 128-bit standard; the terms are interchangeable.

Are these UUIDs cryptographically secure?

The randomness is, yes — it comes from the Web Crypto API. That said, a UUID is an identifier, not a secret; don't use one as a password or an unguessable capability token on its own.

What does a UUID look like?

Thirty-two hexadecimal digits printed in five hyphen-separated groups of 8-4-4-4-12 characters, for example 018f3c4e-7a21-7b3c-9d4e-5f6a7b8c9d0e. The hyphens are formatting only; the value itself is 128 bits.

How do I tell which UUID version I have?

Read the first character of the third group. It is the version digit — 4 for a random UUID v4, 7 for a time-ordered UUID v7. The first character of the fourth group is the variant and is normally 8, 9, a or b.

Should I store a UUID as text or as binary?

As a native type where one exists — PostgreSQL's uuid and SQL Server's uniqueidentifier hold 16 bytes, while the text form costs 36 and makes every comparison a string comparison. In MySQL, BINARY(16) is the equivalent choice.