Naar de inhoud
OneKitly

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

Gepubliceerd op 27-8-2025 · 2 min leestijd · Ontwikkelaarstools

Daniel Okonkwo

Daniel Okonkwo — Front-enddeveloper en techredacteur bij OneKitly

Webprestaties · Bestandsformaten

Getoetst aan 2 bronnen

Profiel bekijken →
Kort gezegd

A UUID (universally unique identifier) is a 128-bit value written as 32 hex digits in five dash-separated groups, like 550e8400-e29b-41d4-a716-446655440000. It's designed to be unique without a central authority, so any system can generate one and rely on it not clashing. Use UUIDs as database keys, request IDs and filenames when you need uniqueness across systems.

Advertentie

A UUID is a 128-bit identifier that's unique without any central authority. Here's what it looks like, why it's useful, the versions, and when to use one.

What a UUID is

A UUID is a 128-bit number, usually shown as 36 characters: 32 hexadecimal digits split into groups of 8-4-4-4-12 by hyphens. With so many possible values — about 3.4 × 10^38 — the chance of two randomly generated UUIDs matching is so small that, in practice, every one is treated as unique. That is the whole point: a label you can mint anywhere and trust.

Advertentie

Why they're useful

The magic is that no coordination is needed. Two servers, a phone that's offline, and a background job can each create UUIDs at the same moment without asking anyone, and the results won't collide. That lets you generate an ID before saving a record, merge data from many sources, or name uploaded files without a central counter handing out numbers.

Versions (v4, v7…)

UUIDs come in versions. Version 4 is fully random and by far the most common. Version 1 mixes a timestamp with the machine's identifier. The newer version 7 puts a timestamp at the front so IDs sort roughly by creation time — which keeps database indexes tidy, a real weakness of random v4. Pick v4 for simplicity, v7 when ordered keys help performance.

When to use — and not

Reach for UUIDs when IDs are created in many places or by clients, when you want to hide how many records exist, or when merging datasets that must not clash. The trade-off is size and order: a UUID is far larger than an integer and, if random, scatters across a database index. For a single database with a simple auto-increment, plain integers are smaller and faster — or use v7 to get UUIDs that still order nicely.

UUID-generatorGenereer UUID v7, v4, v5, v3, v1 of v6 in bulk, in meerdere uitvoerformaten.Probeer de tool →
Advertentie

Veelgestelde vragen

Can two UUIDs be the same?
In theory yes, but for random version-4 UUIDs the odds are so vanishingly small that a collision is treated as impossible.
What's the difference between UUID v4 and v7?
v4 is fully random; v7 embeds a timestamp so the IDs sort by creation time, which is friendlier to database indexes.
Should I use a UUID or an auto-increment ID?
Use UUIDs for distributed or client-generated keys; plain integers are smaller and faster for a single database.

Artikelen die je misschien interesseren

Alle gidsen →

Vergelijkbare tools

Bronnen

Een fout in dit artikel gezien?