UUID, Quick Facts
- •A UUID (Universally Unique Identifier) is a 128-bit value, written as 32 hex digits in five groups: 8-4-4-4-12.
- •This tool generates version 4 (random) UUIDs, the most common type, where 122 of the 128 bits are randomly generated.
- •The odds of two random v4 UUIDs colliding are astronomically small, even generating billions per second.
- •The nil UUID, all zeros (
00000000-0000-0000-0000-000000000000), is reserved to represent "no value."
The Real Problem This Solves
Auto-incrementing IDs (1, 2, 3...) leak information, they reveal how many rows exist and let anyone guess neighbouring records just by changing a number in the URL. They also collide the moment you merge data from two systems or databases.
UUIDs solve both problems: they're unguessable, and safe to generate independently across any number of servers or databases without ever coordinating or colliding.
How Version 4 UUIDs Are Generated
A v4 UUID uses a cryptographically secure random number generator to fill 122 bits with random data. The remaining 6 bits are fixed: 4 bits mark it as "version 4," and 2 bits mark the "variant," so any system can recognise the format at a glance.
Example: in 3fa85f64-5717-4562-b3fc-2c963f66afa6, the "4" right after the second hyphen always identifies a v4 UUID, that position never varies across any valid v4 identifier.
| Version | Based On | Common Use |
|---|---|---|
| v1 | Timestamp + MAC address | Legacy systems needing sortable, traceable IDs |
| v4 | Pure random | Default choice: database keys, session tokens, request IDs |
| v5 | Namespace + name (SHA-1 hash) | Deterministic IDs, the same input always produces the same UUID |
Frequently Asked Questions
Are two UUIDs ever guaranteed to be unique?
Not mathematically guaranteed, but practically yes. With 122 random bits, you'd need to generate around a billion UUIDs per second for roughly 85 years before hitting a 50% chance of a single collision.
Can I use a UUID as a database primary key?
Yes, it's a very common pattern, especially for distributed systems. Note that UUIDs are larger than integers (16 bytes vs 4-8) and, being random, can fragment index performance on very large tables compared to sequential IDs.
What is the difference between a UUID and a GUID?
They are effectively the same thing. GUID (Globally Unique Identifier) is Microsoft's name for the same 128-bit identifier format standardised as UUID.
Is this UUID generated securely?
Yes. When your browser supports it, this tool uses the Web Crypto API's cryptographically secure random number generator, the same one used for secure tokens and keys.
Can I generate the same UUID twice?
With version 4, generating the same UUID twice is not mathematically impossible, but at these odds it will not happen in practice.
Need to validate a UUID format in code?
Test a UUID v4 pattern against real strings, and try the ready-made UUID preset, in our Regex Tester.
Open Regex Tester →