What Is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit label standardized by RFC 4122 that is used to identify information across distributed systems without requiring a central authority. The most common variant, version 4, is generated using cryptographically secure random numbers. With 122 random bits, there are approximately 5.3 undecillion (5.3 x 10^36) possible v4 UUIDs, making the probability of generating two identical values vanishingly small.
UUIDs are used everywhere in modern software. They serve as database primary keys when auto-incrementing integers would leak information about record counts or creation order. Distributed systems rely on them to assign identifiers independently on different nodes without coordination. They also appear as session tokens, correlation IDs for log tracing, and unique file names in object storage systems.
The standard UUID format is five groups of hexadecimal characters separated by hyphens: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx. The "4" in the third group identifies it as version 4, and the leading bits of the fourth group encode the variant. This tool uses the browser's built-in crypto.randomUUID() API when available, ensuring high-quality randomness without sending any data to a server.
Frequently Asked Questions
What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit label used to identify information in computer systems without requiring a central coordinating authority. A version-4 UUID is generated using random or pseudo-random numbers and has 2^122 (approximately 5.3 undecillion) possible values, making accidental collisions virtually impossible in practice.
What is the difference between UUID v1 and v4?
UUID v1 is generated from the current timestamp and the machine's MAC address, which means it encodes when and where it was created. UUID v4 is generated entirely from random numbers, providing no information about its origin. V4 is the most widely used version today because it is simple to generate, does not leak hardware or timing information, and works well in distributed environments where nodes cannot coordinate.
Can two UUIDs ever be the same?
Theoretically yes, but the probability is astronomically low. A v4 UUID has 122 random bits, giving roughly 5.3 x 10^36 possible values. You would need to generate about 2.7 quintillion UUIDs before there is even a 50% chance of a single collision. For all practical purposes in any real-world application, every UUID you generate will be unique.
What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit label used to uniquely identify information in distributed systems without requiring a central authority. UUIDs follow the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and are standardized by RFC 4122. They are widely used as database primary keys, session tokens, correlation IDs, and anywhere a globally unique identifier is needed.
How unique are UUIDs?
Version 4 UUIDs are generated from 122 random bits, producing approximately 5.3 x 10^36 possible values. The probability of generating a duplicate is so low that you would need to create billions of UUIDs per second for decades before a collision becomes statistically likely. For all practical applications, each UUID you generate can be treated as globally unique.
What are the different UUID versions?
The most common UUID versions are v1 (based on timestamp and MAC address), v3 (based on MD5 hash of a namespace and name), v4 (based on random numbers), and v5 (based on SHA-1 hash of a namespace and name). Version 4 is the most widely used because it is simple, does not leak hardware information, and provides excellent uniqueness guarantees through cryptographic randomness.
Can UUIDs be used as database primary keys?
Yes, UUIDs are commonly used as database primary keys, especially in distributed systems where multiple nodes need to generate IDs independently without coordination. The main advantages are global uniqueness and the inability to guess or enumerate records. The trade-off is that UUIDs are larger than auto-incrementing integers (16 bytes vs 4-8 bytes) and random v4 UUIDs can cause index fragmentation in some databases. Using UUID v7 or ordered UUIDs can mitigate the fragmentation issue.