What is a Version-4 UUID (GUID)?
A Universally Unique Identifier (UUID)—also known across the Microsoft ecosystem as a Globally Unique Identifier (GUID)—is a 128-bit label standardized under RFC 4122. In its canonical text representation, a UUID is displayed as 32 hexadecimal digits grouped into five hyphen-separated blocks: 8-4-4-4-12 (for example, c2d4e79b-4395-4bf4-9983-5a0224d4e389).
While earlier specifications derived identifiers from network MAC addresses (v1) or namespaces (v3/v5), UUID Version 4 is generated entirely from pseudo-random numbers. Out of the 128 total bits, 122 bits represent pure cryptographic randomness, providing 2^122 (approximately 5.3 × 10^36) possible unique values.
What is the Probability of a UUID v4 Collision?
The likelihood of generating two identical UUIDs at random is astronomically small. To put this in perspective:
- To have a 50% probability of generating a single collision, you would need to produce 1 billion UUIDs per second continuously for roughly 85 years (approximately 2.71 quintillion UUIDs).
- In a distributed database holding 1 trillion items, the probability of an identifier collision is less than one in a billion.
Frequently Asked Questions
crypto.randomUUID() or crypto.getRandomValues() API, which harnesses operating-system-level entropy (hardware noise and CPU interrupts).