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. The standard is also documented on Wikipedia — Universally unique identifier, which covers the full version history and adoption across operating systems.

A GUID (Globally Unique Identifier) is simply Microsoft’s name for the same standard. UUID and GUID are interchangeable terms for the same 128-bit value. See UUID vs GUID for the one practical difference.

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.

UUID length

A UUID is always 128 bits (16 bytes) in binary. As a string it is 36 characters — 32 lowercase hexadecimal digits plus 4 hyphens in 8-4-4-4-12 groups.

RepresentationLengthNotes
Binary16 bytesNative uuid type (PostgreSQL), BINARY(16) (MySQL)
Hyphenated string36 charsStandard text form, 8-4-4-4-12
No-hyphens string32 chars.hex attribute in Python, "N" format in .NET
Base64url~22 charsCompact, URL-safe encoding

Never store UUIDs as VARCHAR(36). The string representation is 2.25× larger than the binary form, and string comparison is slower than bitwise comparison. Use the native type where the database offers one.

UUID examples

550e8400-e29b-41d4-a716-446655440000   UUID v4 — random
018f3c4e-7a21-7b3c-9d4e-5f6a7b8c9d0e   UUID v7 — time-sortable
6ba7b810-9dad-11d1-80b4-00c04fd430c8   UUID v1 — legacy timestamp
00000000-0000-0000-0000-000000000000   Nil UUID — all zeros
ffffffff-ffff-ffff-ffff-ffffffffffff   Max UUID — all ones

To validate any UUID string, use the UUID Validator.

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. A thorough statistical treatment is covered in research published through NIH PubMed Central on probabilistic uniqueness in distributed identifiers.

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.

Further reading

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.

What is the difference between UUID and GUID?

GUID (Globally Unique Identifier) is Microsoft's name for the same 128-bit standard. UUID is used everywhere else — PostgreSQL, MySQL, JavaScript, Python, Go. The values and the format are identical. See UUID vs GUID for the one practical difference (SQL Server byte order).

How long is a UUID?

A UUID is 128 bits (16 bytes) in binary. As a string it is 36 characters — 32 hex digits plus 4 hyphens. The native uuid type in PostgreSQL and the uniqueidentifier type in SQL Server both store 16 bytes. Never use VARCHAR(36) — it wastes space and slows comparisons.

What is a UUID used for?

UUIDs identify database rows, API resources, events, and files across distributed systems without a central authority. They appear as primary keys, idempotency keys, correlation IDs, and share links. Use UUID v7 for database keys (sortable) and UUID v4 for public URLs (no timestamp leakage).