A UUID and a GUID are the same 128-bit value written the same way: 32 hexadecimal digits in five groups, 8-4-4-4-12, like f47ac10b-58cc-4372-a567-0e02b2c3d479. UUID is the term in the standard; GUID is Microsoft’s name for it.
The interesting question is not the name. It is which version, because the version decides whether the identifier leaks the time, sorts well in a database, or is just random.
The format
| Part | Digits | What it is |
|---|---|---|
| time_low | 8 | First 32 bits |
| time_mid | 4 | Next 16 bits |
| time_hi_and_version | 4 | 16 bits, first nibble is the version |
| clock_seq | 4 | 16 bits, first bits are the variant |
| node | 12 | Last 48 bits |
The version is the first character of the third group. 4372 means version 4. 7f3a would mean version 7.
The versions worth knowing
| Version | Based on | Sorts by time | Leaks |
|---|---|---|---|
| v1 | Timestamp + MAC address | Roughly | Your machine’s MAC and the exact time |
| v4 | 122 random bits | No | Nothing |
| v7 | Unix milliseconds + random | Yes | The creation time, to the millisecond |
v1 is the original and the one to avoid in public identifiers: it embeds the MAC address of the machine that generated it, which is a hardware fingerprint.
v4 is the default in most libraries. It is pure randomness, unguessable, and it has no order at all — which is exactly its problem as a database key.
v7, standardised in 2024, puts a millisecond timestamp at the front and randomness after it. Inserted keys arrive in chronological order, so the index does not have to rebalance on every insert. For a primary key in a busy table, that is a real difference.
The collision question
A v4 UUID has 122 random bits. To have a 50% chance of any collision you would need to generate roughly 2.7 × 10¹⁸ of them — and at a billion per second that is about 85 years of continuous generation.
In practice: generate as many as you like. The birthday paradox makes people nervous about random identifiers, but the numbers are not close.
When to use which
- Database primary key, high insert rate → v7.
- Anything public, tokens, file names → v4 (never v1).
- Interoperability with an old system → whatever that system speaks; converting is just a string.
- Human-readable ID → none of the above. A UUID is for machines; a short slug is for people.
The UUID generator produces v4 and v1 in the browser, with the option to strip the hyphens for compact storage. Nothing is sent anywhere, which matters more than it sounds: an identifier generated on a server is an identifier that server has seen.
A UUID is a number that promises never to be issued twice. The version is how it keeps the promise.
Hero photo: Circuit board, CC0, via Openverse (Flickr).
