What is a UUID?
A UUID (universally unique identifier, also called a GUID) is a 128-bit identifier written as 32 hexadecimal digits in five groups, e.g. 3f2b8c1e-9d4a-4f6b-a2c7-1e5d8b9f0a34. The generator creates version 4 UUIDs — 122 bits are random and the rest mark the version and variant (which is why the third group always starts with “4”).
Can a UUID repeat?
In theory yes, in practice no. There are about 5.3 × 10³⁶ possible v4 UUIDs. For a 50% chance of a single duplicate you’d need about 2.7 × 10¹⁸ of them — at a billion per second that would take about 85 years.
Where UUIDs are used
- Database keys — they can be created in the application without asking the database for the next number.
- IDs for orders, files, sessions and events in distributed systems.
- Test data and application configuration.
Frequently asked questions
What is the difference between a UUID and a GUID?
They are the same thing — GUID is the name used mainly by Microsoft. The format and length are identical.
Can I use a UUID as a password or token?
A v4 UUID from a cryptographic generator is hard to guess, but that isn’t its purpose — for passwords and API keys, use dedicated generators and longer random strings.