UUID v4 vs v7 vs GUID
All three are the same 128-bit identifier in the same 8-4-4-4-12 format. What differs is how the bits are filled - and that decides how well they behave as a database key.
| UUID v4 | UUID v7 | GUID | |
|---|---|---|---|
| What fills it | 122 random bits | 48-bit timestamp + 74 random bits | Microsoft’s name for the same standard |
| Sortable by time | No | Yes, to the millisecond | Depends on version |
| Database index behaviour | Random inserts fragment the index | Inserts append, like an auto-increment key | As per its version |
| Leaks creation time | No | Yes - the timestamp is readable | Depends on version |
| Typical use | Public IDs, tokens, anything where unpredictability matters | Primary keys, event logs, anything inserted in volume | .NET and Windows APIs |
The practical rule: use v7 for database primary keys, and v4 when the identifier is exposed publicly and its creation time should stay private.
How likely is a UUID collision?
A version 4 UUID has 122 random bits, giving about 5.3 × 1036 possible values. The risk grows with the square of how many you generate, so it is small but not negligible at extreme volumes: generating a billion UUIDs a second for a century (about 3.16 × 1018 UUIDs) works out to roughly a 61% chance of at least one collision somewhere in that set. For virtually any real application - even one issuing millions of IDs - the probability is astronomically small; problems in practice come from a broken random source, never from exhausting the space, which is why the generator above uses the browser’s cryptographic crypto.getRandomValues rather than Math.random.
Reading a UUID
| Position | Characters | Meaning |
|---|---|---|
| Overall | 36 | 32 hex digits plus 4 hyphens |
| Group pattern | 8-4-4-4-12 | The canonical hyphenated form |
| 15th character | 1 | The version digit - 4 for random, 7 for time-sortable |
| 20th character | 1 | The variant - 8, 9, a or b for the RFC 9562 layout |
Related developer tools
What is a UUID?
A UUID is a 128-bit identifier written as 36 characters in the pattern 8-4-4-4-12, such as 3f2b8c1e-4a5d-4e7f-9b0a-1c2d3e4f5a6b. UUIDs are generated independently with no central coordinator, and the space is large enough that random v4 collisions are not a practical concern.
What is the difference between UUID v4 and v7?
UUID v4 is fully random, which makes it unpredictable but poorly ordered - random inserts fragment database indexes. UUID v7 puts a millisecond timestamp in the leading bits, so v7 values sort chronologically and index far better, while keeping enough randomness to stay unguessable.
Is a GUID the same as a UUID?
Yes, in practice. GUID is Microsoft's name for the same 128-bit identifier standard that everyone else calls a UUID, and the two are interchangeable in format and length. GUIDs are sometimes displayed wrapped in braces, but the underlying value is identical.
Runs in your browser. Your files and text never leave your device - nothing is uploaded.
