UUID Versions Explained: What They Are and When to Use Each

A UUID is a 128-bit ID you can create anywhere without clashing with anyone else's. Version 4, built from random bits, is the right default. Version 7 adds a timestamp so IDs sort by creation time, which suits database keys.

What a UUID is

A UUID (Universally Unique Identifier), also called a GUID in Microsoft systems, is a 128-bit number used as an ID that won't clash with anyone else's, without a central authority handing numbers out. It's written as 32 hexadecimal digits in five groups:

f47ac10b-58cc-4372-a567-0e02b2c3d479

Two positions tell you what kind of UUID it is. The first digit of the third group is the version (here 4). The first digit of the fourth group is the variant, which for standard UUIDs is 8, 9, a or b (here a).

The versions

UUIDs are defined in RFC 9562 (2024), which replaced the original RFC 4122. The versions you'll meet:

VersionBuilt fromSortable by timeUse today
v1Timestamp + device's MAC addressNot directlyLegacy; can reveal the machine and time
v3MD5 hash of a namespace + nameNoSame input always gives the same UUID; prefer v5
v4122 random bitsNoThe default choice for most purposes
v5SHA-1 hash of a namespace + nameNoStable IDs derived from names, like URLs
v6Reordered v1 timestampYesFor systems migrating from v1
v7Unix time in milliseconds + random bitsYesDatabase keys that should sort by creation time
v8Custom layoutDependsExperimental or vendor-specific formats

Will two random UUIDs ever collide?

A version 4 UUID has 122 random bits, so there are 2122, about 5.3 × 1036, possible values. Using the birthday-problem formula, the chance that at least two UUIDs in a set are identical is:

UUIDs generatedChance of any duplicate
1 million (106)about 1 in 1025
1 billion (109)about 1 in 1019
1 trillion (1012)about 1 in 10 trillion
1 quadrillion (1015)about 1 in 10 million
2.7 × 101850%

Generating a billion UUIDs every second, it would take about 86 years to reach a 50% chance of a single duplicate. In practice, bugs such as a poor random number generator or copying the same ID twice are far more likely than a true collision. That's why the random source matters: the UUID Generator uses the browser's Web Crypto API, a cryptographically secure generator.

v4 or v7?

Use v4 when you just need a unique, unguessable ID: request IDs, file names, public identifiers in URLs, test data.

Consider v7 for primary keys in large databases. Because v7 starts with a timestamp, new IDs sort after older ones. Databases store rows in index order, so inserting random v4 keys scatters writes across the index, while v7 keys append near the end, which is usually faster and keeps indexes smaller. The trade-off: a v7 ID reveals roughly when it was created. Its 48-bit millisecond timestamp won't run out until the year 10889.

Formatting options

  • Hyphens: the standard form has 36 characters including 4 hyphens. Removing them leaves 32 hexadecimal characters, which some systems prefer. Both represent the same value.
  • Case: UUIDs are case-insensitive. Lowercase is the standard output; some Microsoft tools display uppercase.
  • Storage: in a database, store UUIDs in a native UUID type or as 16 bytes, not as a 36-character string, to save space and speed up comparisons.

Generating UUIDs

  1. Open the UUID Generator.
  2. Choose how many you need, up to 100 at a time.
  3. Optionally switch to uppercase or remove hyphens.
  4. Copy the list. The IDs are generated in your browser and not sent anywhere.

The tool generates version 4 UUIDs, the right default for most uses.

What UUIDs are not

  • Not secret tokens by design. A v4 UUID is hard to guess, but for password reset links or API keys, use a purpose-built token with more randomness and an expiry.
  • Not meaningful. Don't parse information out of v4 UUIDs; there isn't any.
  • Not short. For human-facing codes, like order numbers people read over the phone, use something shorter.

Frequently asked questions

Is a GUID the same as a UUID?

Yes. GUID is Microsoft's name for the same 128-bit identifier format.

How can I tell which version a UUID is?

Look at the first character of the third group. In f47ac10b-58cc-4372-a567-0e02b2c3d479 it's 4, so it's version 4.

Can two computers generate the same v4 UUID?

In theory yes, in practice no: with a proper random source the probability is too small to matter for any real system.

Should I use UUIDs or auto-increment numbers?

Auto-increment numbers are small and simple but reveal how many records exist and need one central database. UUIDs can be created anywhere without coordination.

Related

Sources