What is UUID v4?
A 128-bit identifier produced from 122 random bits plus 6 fixed bits identifying it as version 4 (random) and variant RFC 4122. The probability of collision is so small (≈ 1 in 2.71 × 10¹⁸ for 1 billion UUIDs) that they're treated as universally unique without coordination.
Format examples
- Standard:
550e8400-e29b-41d4-a716-446655440000 - No hyphens:
550e8400e29b41d4a716446655440000 - Braces (Microsoft style):
{550e8400-e29b-41d4-a716-446655440000}
FAQ
Are these cryptographically random?
Yes — they use crypto.getRandomValues (the same source that backs crypto.randomUUID() in modern browsers). Falls back to Math.random only on very old browsers.
Why not v1 (timestamp-based)?
v1 leaks the MAC address and timestamp of the generator, which is usually not desirable. v4 is the right choice for almost every "give me a unique ID" use case.