Kit-Bin
Donate

← All guides

What Is a UUID, and Why Do They Look Like That?

A UUID looks like 3f29c9a2-6b4e-4b1a-9c2e-8e2f6a1d4b7c, 32 hexadecimal characters split into five groups by hyphens. The format looks arbitrary until you know what each piece is actually doing.

  • 36 characters total, written out — 32 hex digits plus 4 hyphens.
  • 32 hex digits, each one representing 4 bits.
  • 128 bits total (122 of them random, in the common v4 case — see below).
  • The hyphens carry zero information. They exist purely for human readability.

128 bits, formatted for humans

A UUID (Universally Unique Identifier) is a 128-bit number. Written out in raw binary or decimal it would be unreadable, so the standard displays it as 32 hex digits, each representing 4 bits. The 8-4-4-4-12 grouping and the hyphens between them carry zero information, they're not padding, a checksum, or a separator between meaningful fields in the way a phone number's area code is. They exist purely so a human reading a UUID can parse it into chunks instead of squinting at 32 unbroken characters. Strip every hyphen out and you get the identical number.

The version and variant bits

Not all 128 bits are random, even in the most common UUID type. A handful are reserved to identify which UUID scheme produced the value. The first character of the third group is the version nibble, in a v4 UUID that character is always 4, as in the example above. It tells any code reading the UUID "this was generated with the random-based algorithm," as opposed to the timestamp-based v1 scheme or others. A couple of bits at the start of the fourth group are the variant, marking which broader UUID layout standard is in use (in practice, almost every UUID you'll encounter uses the same variant). These reserved bits are why a v4 UUID has 122 random bits, not the full 128, six are spoken for.

The actual collision math

This is the part most explanations wave away with "practically impossible." Here's the real number. With 122 random bits, there are 2^122 possible v4 UUIDs, a number with 37 digits. The relevant question isn't how many UUIDs exist, it's how many you'd have to generate before two of them happened to match, which is the classic birthday-problem calculation: collision odds grow with the square of how many you've generated, not linearly.

Working that through for a 50% chance of at least one collision anywhere in the batch gives roughly 2.71 quintillion UUIDs, that's 2.71 x 10^18. To put that in perspective: generating one billion UUIDs every single second, nonstop, it would take about 86 years to reach that number. Real-world systems generate nowhere near that volume, which is why UUID collisions in practice are usually a sign of a broken random number generator, not bad luck.

Generating one

Kit-Bin's UUID Generator produces v4 UUIDs using the browser's built-in cryptographically secure random number source, entirely on your device.

Related guide

v4 isn't the only version in use. See UUID v1 vs v4 vs v7 for why the timestamp-based versions still matter, especially for database design.

Source: RFC 9562: Universally Unique IDentifiers (UUIDs)

Written by the Kit-Bin teamPublished Spotted an error? Tell us