What is a UUID?
A UUID (universally unique identifier) is a 128-bit ID written as 32 hex digits in five groups: 8-4-4-4-12, e.g. 550e8400-e29b-41d4-a716-446655440000. Because they're unique without a central counter, apps, databases and APIs use them for IDs that can be created anywhere. The first digit of the third group is the version.
UUID versions
| Version | How it's made | Use it for |
|---|---|---|
| v1 | Timestamp + MAC address | Legacy systems (leaks the machine and time) |
| v3 / v5 | Hash (MD5 / SHA-1) of a namespace and name | The same ID for the same input every time |
| v4 | 122 random bits | General-purpose IDs; the most common version |
| v6 | v1 reordered to sort by time | Migrating from v1 |
| v7 | Unix milliseconds + random bits | Database keys and anything that should sort by creation time |
Generate a UUID in code
crypto.randomUUID(); // v4, in browsers and Node.js 19+import uuid
uuid.uuid4() # random
uuid.uuid7() # time-ordered (Python 3.14+)SELECT gen_random_uuid(); -- v4 (PostgreSQL 13+)
SELECT uuidv7(); -- v7 (PostgreSQL 18+)import "github.com/google/uuid"
id := uuid.New() // v4
id7, err := uuid.NewV7() // v7UUID id = UUID.randomUUID(); // v4Guid.NewGuid(); // v4
Guid.CreateVersion7(); // v7 (.NET 9+)uuidgen # macOS and most Linux distributionsUUIDs in APIs
Many APIs use UUIDs as resource IDs, and some ask clients to send one as an idempotency key so a retried request (after a timeout or a 504) isn't processed twice. Generate one per logical operation, not per retry. Browse free APIs by category to see them in action.