HomeGuides What Is a UUID (and When to Use One)?

What Is a UUID (and When to Use One)?

A UUID is a 128-bit identifier you can generate anywhere, at any time, without coordinating with a server — and still be confident it is unique across the whole world. That property makes it a staple of modern software. Here is how it works.

What a UUID is

UUID stands for Universally Unique Identifier — 128 bits usually written as 32 hexadecimal digits in five groups separated by hyphens, like 8-4-4-4-12. The point is decentralised uniqueness: any machine can mint one on its own and it will not clash with any other.

Version 4 vs version 1

The most common form, version 4, is almost entirely random. Version 1 builds the ID from the current time and the machine's network address, so it is roughly sortable by creation time but leaks a little about where it came from. For most uses, the random version 4 is the safe default.

Why collisions are effectively impossible

A version-4 UUID has 122 random bits — about 5 x 10^36 possibilities. You could generate billions per second for a lifetime and the chance of ever repeating one stays vanishingly small. That is why applications trust them as primary keys without checking a central registry.

Where to use one

UUIDs are ideal as database keys generated on the client before a record is saved, as identifiers in distributed systems where no single authority hands out IDs, and as unguessable tokens in URLs. They are longer and less friendly than a simple counter, so where a small sequential number would do and there is a central database, that can be simpler. The UUID Generator here creates version-4 UUIDs in your browser.

Frequently asked questions

Can two UUIDs ever be the same? In theory yes, in practice no — the odds are so small they are ignored in real systems.

Are UUIDs random or ordered? Version 4 is random; version 1 and newer time-ordered variants are roughly sortable by time.

Is a UUID secret? Not inherently — it is unique, not secret, though its randomness makes version 4 hard to guess.

Related tools

Last updated: August 27, 2026