← Learn

What Is a UUID?

Updated 8 May 2026

A plain-English guide to UUIDs — what they are, how they are structured, the difference between v4 and v7, and when to use a UUID as a database primary key.

What a UUID is

A UUID (Universally Unique Identifier) is a 128-bit number used to identify things — database rows, API resources, session tokens, files, and anything else that needs a globally unique label. The defining feature is that UUIDs can be generated on any machine at any time without checking a central registry, yet collisions are so statistically rare they are treated as impossible in practice.

UUID format — 32 hex digits, 4 hyphens, 5 groups
550e8400-e29b-41d4-a716-446655440000
xxxxxxxx — 8 hex = time_low (v7) or random (v4)
xxxx — 4 hex = time_mid
4xxx — version digit + 3 hex
yxxx — variant bits + 3 hex
xxxxxxxxxxxx — 12 hex = random node

UUID vs GUID — the same thing

Microsoft calls them GUIDs (Globally Unique Identifiers). The format and generation algorithm are identical. You will see both terms depending on the technology stack — UUID in Linux/web/database contexts, GUID in Windows/.NET contexts.

UUID versions

VersionHow it is generatedUse today?
v1MAC address + timestampAvoid — leaks hardware identity
v3MD5 hash of namespace + nameLegacy only
v4Fully random (122 random bits)Yes — widely supported default
v5SHA-1 hash of namespace + nameWhen deterministic IDs needed
v7Unix timestamp (ms) + randomYes — preferred for databases

Why UUID v7 is better for databases

UUID v4 is purely random. When used as a database primary key in a B-tree index, new rows are inserted at random positions — this causes page splits and index fragmentation, which degrades write performance at scale.

UUID v7 embeds a millisecond Unix timestamp in the first 48 bits. This means new UUIDs are always greater than earlier ones, so inserts go to the end of the index — the same pattern as an auto-incrementing integer. You get global uniqueness without the performance penalty.

Common uses

  • Database primary keys — UUID v7 is ideal; v4 works but fragments indexes
  • API resource identifiers — expose UUIDs rather than sequential integers to avoid enumeration attacks
  • Session tokens and correlation IDs — easy to generate, globally unique across distributed systems
  • Idempotency keys — generate a UUID client-side so retried requests are deduplicated server-side
  • File names — avoid collisions when uploading files from multiple sources

Related guides

Generate UUID v4 and v7 online

Bulk generate, copy all, toggle uppercase or braces — instantly in the browser

Open UUID Generator →