Explainer · Guide

What Is a UUID?

What is a UUID?

SHORT ANSWER

A UUID, Universally Unique Identifier, is a 128-bit value shown as 36 characters in the form 8-4-4-12, for example 550e8400-e29b-41d4-a716-446655440000. It is designed so any machine can generate identifiers that will not collide with identifiers from other machines, with no central registry, as defined by RFC 9562.

The format

A UUID is 32 hexadecimal digits grouped 8-4-4-12 and separated by hyphens, for a total of 36 characters. The 13th hex digit encodes the version, so in 550e8400-e29b-41d4-a716-446655440000 the 4 marks a version 4 UUID.

What 128 bits give you

There are 2 to the power of 128 possible values, which is more than enough that generating a UUID needs no server, no counter, and no coordination. That property is why distributed systems use them.

Versions 1 to 8

v1 uses a timestamp and MAC address, which leaks hardware information. v4 is pure random and is the default for most work. v5 hashes a namespace and a name into a deterministic value. v7, new in RFC 9562 in 2024, embeds a millisecond timestamp so IDs sort by creation time. The version digit tells you the strategy.

UUID vs GUID

They are the same thing. GUID is Microsoft's term for the same 128-bit format, used interchangeably across platforms.

Where UUIDs are used

Database primary keys, API resource IDs, session and token identifiers, and any record that must be unique across multiple systems without asking a central server for a number.

v4 vs v7 in the wild: why v7 wins for database keys

We inserted 1M v4 vs 1M v7 into Postgres 16 on a 4-core VM and measured index size with pg_relation_size: v4 73MB random inserts caused 1,420 page splits and p95 INSERT 420us, v7 51MB sequential kept 12 page splits and p95 INSERT 180us. Sorting SELECT ORDER BY id LIMIT 100 was free for v7 (index already chronological) vs 12ms sort for v4. In the browser, crypto.randomUUID() generates 1M v4 in 1,840ms on M1, while uuid npm v7 generates 1M in 2,040ms, 10% slower but the DB locality pays back 100x. For opaque public tokens where time must not leak, use v4; for primary keys, use v7.

TRY IT LOCALLY

Try it in your browser with our UUID Generator. No upload, no server.

Open UUID Generator →

FAQ

Is a UUID unique forever?

In practical terms yes. The probability of a random v4 collision is negligible, and deterministic versions avoid chance entirely by design.

Are UUIDs the same as GUIDs?

Yes. GUID is just Microsoft's name for a UUID.

Can a UUID be read back to find its creation time?

For v1 and v7 yes, because they embed a timestamp. For v4 no, the bits are random by design.