A UUID (Universally Unique Identifier) is a standard for generating identifiers that, with overwhelming probability, never repeat—locally or anywhere else. In development they’re used mainly for resource IDs in APIs, databases and distributed systems.
What is a UUID?
A UUID is a 128-bit number written in hexadecimal with hyphens, e.g.: 550e8400-e29b-41d4-a716-446655440000. The most common version is v4, which is generated randomly (or pseudo-randomly). Other versions (e.g. v1 based on time and MAC) exist, but in modern APIs and databases v4 is often chosen for simplicity and because it doesn’t encode extra information.
Advantages over auto-increment IDs
- No central coordination: you can generate UUIDs on the client, on multiple servers or in different processes without a database assigning the “next” number.
- Non-sequential: the next ID can’t be guessed and resources can’t be enumerated easily, which matters for public APIs.
- Merging data: if you later combine data from multiple sources, UUIDs avoid collisions between numeric IDs.
- Security: they don’t reveal record count or creation order.
The tradeoff is that they take more space (16 bytes or 36 characters in the standard representation) and are less human-friendly than a small integer.
When to use UUIDs
- REST APIs: resource identifiers in URLs (
/users/{uuid}). - Distributed or replicated databases: when multiple instances create records.
- Events and queues: identifying messages uniquely without a central counter.
- Tokens or references: when you need a unique value that isn’t sequential.
You can use an online UUID generator to get v4 values for testing or documentation. In code, most languages have standard or popular libraries (e.g. uuid in Node.js, uuid in Python) that generate valid UUID v4.