What is a UUIDv4?
A UUID (Universally Unique Identifier) is a 128-bit identifier that is unique across space and time. Version 4 UUIDs are generated using random or pseudo-random numbers, making collisions virtually impossible. The probability of generating two identical UUIDv4s is roughly 1 in 5.3×1036.
UUIDv4 follows the format
xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx,
where 4
indicates the version and
y
is one of 8,
9,
a, or
b,
indicating the variant. The variant field marks this as an RFC 4122 UUID
(variant 1), distinguishing it from older Apollo NCS UUIDs (variant 0), Microsoft GUIDs
(variant 2), and reserved formats. Within variant 1, the original
RFC 4122 defined five versions:
v1 (timestamp + MAC address),
v2 (DCE security),
v3 (MD5 namespace hash),
v4 (random), and
v5 (SHA-1 namespace hash).
RFC 9562 later introduced three more:
v6 (reordered timestamp for sortability),
v7 (Unix epoch timestamp + random), and
v8 (custom/vendor-specific).
Version 4 remains by far the most common because it requires no coordination or shared
state, just a cryptographically secure random number generator. Version 7 is gaining
adoption for use cases that benefit from time-sortable IDs.
UUID Version Comparison
| Version | Name | Generation Method |
|---|---|---|
| v1 | Timestamp | Current time + MAC address of the host |
| v2 | DCE Security | Timestamp + MAC address + local domain ID |
| v3 | MD5 Hash | MD5 hash of a namespace + name |
| v4 | Random | Cryptographically secure random numbers |
| v5 | SHA-1 Hash | SHA-1 hash of a namespace + name |
| v6 | Reordered Timestamp | v1 timestamp reordered for lexicographic sortability |
| v7 | Unix Epoch Timestamp | Unix timestamp in ms + cryptographic random bits |
| v8 | Custom | Vendor-specific or application-defined format |
Common Use Cases for UUIDs
UUIDs are widely used as database primary keys, API request identifiers, session tokens, and distributed system trace IDs. Unlike auto-incrementing integers, they can be generated independently on any node without coordination, making them ideal for microservices and event-driven architectures.
Frequently Asked Questions
- How do I generate a UUIDv4?
- A fresh UUIDv4 is generated automatically when you load this page using the Web Crypto API. Click "Generate New UUID" for another one, and use the copy button to copy it to your clipboard instantly.
- How do I validate a UUIDv4?
- Paste your UUID into the validator and click "Validate UUID". The tool checks each character position against the UUIDv4 specification. Valid characters are highlighted in green, invalid ones in red, with explanations for each error on hover.
- Are UUIDv4s truly unique?
- While not mathematically guaranteed, the probability of generating two identical UUIDv4s is approximately 1 in 5.3×1036. You would need to generate roughly 2.71 quintillion UUIDs to have a 50% chance of a single collision, making them effectively unique for all practical purposes.
- What is the difference between a UUID and a GUID?
- UUID (Universally Unique Identifier) and GUID (Globally Unique Identifier) refer to the same concept. "GUID" is the term historically used by Microsoft, while "UUID" is the standard term used in RFC 4122. They are functionally identical.
- Which UUID version should I use?
- For most applications, UUIDv4 is the best choice. It's simple, requires no coordination, and uses cryptographically secure random numbers. If you need time-sortable IDs (e.g., for database indexing), consider UUIDv7, which embeds a Unix timestamp while retaining randomness.
- Is my data sent to a server?
- No. UUIDs are generated and validated entirely in your browser using the Web Crypto API. Nothing is sent to any server.