What Is a UUID?

By Freddy ·

A UUID (Universally Unique Identifier) is a 128-bit value used to identify information without requiring a central authority to hand out the ids. “GUID” (Globally Unique Identifier) is the same thing under a different name, coined by Microsoft; the two terms are used interchangeably.

A UUID is conventionally written as 32 hexadecimal digits split into five groups by hyphens, in the pattern 8-4-4-4-12, for example f47ac10b-58cc-4372-a567-0e02b2c3d479. That structure isn't arbitrary: certain digits encode the UUID's version and variant, which is how software can tell a v4 UUID apart from a v5 one just by looking at it.

Why not just use an incrementing number?

The short version: an auto-incrementing integer needs a single authority handing out the next number, which falls apart the moment more than one system is creating records independently. A UUID sidesteps that entirely by being generated with no coordination and a practically zero chance of collision. The full tradeoffs, storage cost, index fragmentation, when an integer is still the better call, are their own topic, covered in UUID vs Auto-Increment ID: Which Should Your Database Use?

The three versions in everyday use

  • v4: random. Generated from 122 bits of randomness with no embedded information. This is the default choice for primary keys, session tokens, and correlation ids when there's no reason to encode meaning into the identifier itself.
  • v1: timestamp-based. Encodes the creation time and a node identifier (traditionally a MAC address) directly into the id, making v1 UUIDs sortable by creation order. The tradeoff is that anyone who sees a v1 UUID can extract when, and on what machine, it was generated, so it's a poor fit when the identifier is public-facing and anonymity matters.
  • v5: deterministic. Computed as a SHA-1 hash of a namespace UUID plus a name string, so the same inputs always produce the same output. Useful for deriving a stable id from something you already have (a URL, an email address, a file path) without needing a lookup table to remember what id you assigned it last time.

Need to generate some? The GUID / UUID Generator on this site creates v1, v4, and v5 identifiers in bulk, entirely in your browser. Nothing is sent to a server.

← Back to KeyForge