What is a UUID
UUID stands for Universally Unique Identifier. It is a 128-bit number, typically represented as a sequence of 32 hexadecimal characters separated by hyphens, used to identify records in a way that is practically unique without needing a central database controlling the numbering, unlike a traditional sequential ID.
UUID format
A UUID follows the pattern xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx, where each x is a hexadecimal character (0 to 9, a to f), the M digit indicates the UUID version, and the leading bits of the N digit indicate the variant used. This calculator generates version 4 UUIDs, the most common one in use today, which is entirely based on random numbers.
Why use a UUID instead of a sequential ID
Sequential IDs (1, 2, 3...) are simple, but they require a single point of control generating numbers in order, which complicates distributed systems with multiple servers creating records at the same time. UUIDs solve this problem because any system can generate a new UUID independently, without consulting a central server, with a collision probability so low that it is safe to treat them as unique in practice.
Collision probability of a UUID v4
A UUID v4 has 122 bits of randomness, since the other 6 bits are fixed to indicate the version and variant. That works out to roughly 5.3 undecillion possible combinations. To put that scale in perspective, you would need to generate billions of UUIDs per second, continuously, for billions of years, to have a reasonable chance of generating two identical UUIDs by accident.
Validating a UUID's format
Not every string in the "8-4-4-4-12" character pattern is a valid UUID: the version, indicated by the first digit of the third group, must be between 1 and 5, and the variant, indicated by the leading bits of the fourth group, must follow the pattern defined by RFC 4122. The validation calculator on this page checks those rules and reports the detected version, or flags when the text is not a valid UUID.