What Is a UUID? Versions, Uses, and How to Generate One
A UUID is that 36-character string of hex and dashes you see as database IDs and request identifiers. Here's what it is, why it works, and when to reach for one.
What a UUID is
A UUID (Universally Unique Identifier) — also called a GUID on Microsoft platforms — is a 128-bit value written as 32 hexadecimal digits in five dash-separated groups:
f47ac10b-58cc-4372-a567-0e02b2c3d479
Its whole purpose is to be unique without coordination — any machine can generate one and be confident it won't collide with one generated elsewhere.
The common versions
- v4 (random) — almost entirely random. The most widely used because it needs no inputs and no central authority. This is the default for most apps.
- v1 (time-based) — derived from a timestamp and machine identifier.
- v5 (name-based) — a hash of a namespace plus a name, so the same input always yields the same UUID.
How unique is "unique"?
A v4 UUID has 122 random bits. The number of possibilities is so vast that the practical chance of ever generating the same one twice is negligible — which is why systems treat them as safe to use as primary keys without checking for collisions.
When to use a UUID
- Database keys you want to generate on the client or across many services without a central sequence.
- Correlation / request IDs for tracing a request through logs.
- Idempotency keys so a retried operation isn't processed twice.
If you need short, human-friendly, or strictly ordered IDs, a sequence or a different scheme may fit better — UUIDs trade brevity for decentralized uniqueness.
Try it
Generate one v4 UUID or a whole batch, ready to copy — created in your browser, nothing uploaded.