How the UUIDs are made
A UUID is 128 bits written as 32 hex digits in five groups. Four bits say the version and two or three bits the variant; the rest depends on the version. RFC 9562, published in 2024, replaced the older RFC 4122 and added versions 6, 7 and 8.
v4 xxxxxxxx-xxxx-4xxx-Vxxx-xxxxxxxxxxxx v7 tttttttt-tttt-7ccc-Vxxx-xxxxxxxxxxxx t = Unix time in ms (48 bits) c = counter or random (12 bits) x = random, V = 8, 9, a or b
Version 4 fills the other 122 bits with random data; this page asks your browser's cryptographic random generator for it. Version 7 starts with the Unix time in milliseconds (48 bits), so UUIDs made later sort after earlier ones, and fills the rest with random bits. When many are made in the same millisecond, the 12 bits after the version act as a counter, as RFC 9562 allows, so a list of 1,000 is still in order.
The checker reads the version and variant bits of any UUID, and for versions 1, 6 and 7 the time stored in it. A v4 UUID carries no time, so nothing can be read from it but its version.
Example
The example in RFC 9562 is 017f22e2-79b0-7cc3-98c4-dc0c0c07398f. The first 12 hex digits, 017f22e279b0, are 1,645,557,742,000 milliseconds since 1970: 22 February 2022, 19:22:22 UTC. The 7 after the second hyphen is the version, and the 9 after the third marks the standard variant.
Questions
UUID v4 or v7: which should I use?
Use v7 for database primary keys: new rows get larger IDs, so they go to the end of the index instead of random places, which keeps inserts fast and indexes compact. Use v4 when the ID must not reveal when it was made, for example in a public link. Both are unique enough for any practical purpose.
Can two UUIDs ever be the same?
In theory yes, in practice no. A v4 UUID has 122 random bits: you would need to make about 2.7 quintillion (2.7 × 10^18) of them for a 50% chance of a single duplicate. A v7 UUID has 62 to 74 random bits behind its millisecond timestamp, depending on how it is made, so a collision would need enormous numbers made in the same millisecond. Bad random number generators, not the format, cause duplicates.
Is a GUID the same as a UUID?
Yes. GUID is Microsoft's name for the same 128-bit identifier, and Guid.NewGuid() in .NET makes a version 4 UUID. Microsoft tools often write GUIDs in uppercase and in braces: use the options above to get that form.
Does a v7 UUID reveal when it was made?
Yes, to the millisecond: paste one into the checker above and it shows the time. That is what makes them sort well, but it also tells anyone who sees the ID when the record was created. If that matters, use v4 for the IDs you show publicly.
How do I make a UUID on the command line?
On Linux: cat /proc/sys/kernel/random/uuid or uuidgen. On macOS: uuidgen (uppercase). In PostgreSQL: gen_random_uuid() for v4, and uuidv7() from version 18. In Python: import uuid; uuid.uuid4(), and uuid.uuid7() from Python 3.14. In JavaScript: crypto.randomUUID().