What is UUID (Universally Unique Identifier)?

A UUID is a 128-bit identifier designed to be unique across space and time without a central authority, written as 32 hex digits in five groups.

A UUID, or Universally Unique Identifier, is a 128-bit value used to label information so that identifiers generated independently on different systems are effectively guaranteed not to collide. It is written as 32 hexadecimal digits split into five hyphen-separated groups in the pattern 8-4-4-4-12, for example 550e8400-e29b-41d4-a716-446655440000. UUIDs are also called GUIDs in some ecosystems.

The key advantage of UUIDs is decentralized generation. Because the space of possible values is astronomically large, any machine can create a UUID at any time without coordinating with a central server, and the odds of two independently generated UUIDs matching are negligible. This makes UUIDs ideal for distributed systems, offline data creation, and merging records from multiple sources.

There are several versions. Version 4 is the most common, using random or pseudo-random bits, and is the default choice for most applications. Version 1 encodes a timestamp and machine identifier, and newer versions like v7 are time-ordered, which improves database index performance while retaining uniqueness. The version is encoded in one of the digits, so you can identify it from the string itself.

UUIDs are widely used as primary keys, correlation IDs for tracing requests across services, idempotency keys, and identifiers in APIs and event streams. The trade-offs versus sequential integer IDs are size and readability - UUIDs are longer and not human-friendly - and, for random versions, poorer database locality, which time-ordered variants and alternatives like ULID were designed to address.

Examples

  • 550e8400-e29b-41d4-a716-446655440000 - a version 4 UUID
  • Using a UUID as a database primary key generated on the client
  • A correlation ID tagging one request as it flows across microservices

Common questions

Are UUIDs truly unique?
Not with mathematical certainty, but the probability of a collision is so small it is negligible in practice. For version 4, you would need to generate billions of UUIDs before a collision became remotely likely.
Which UUID version should I use?
Version 4 (random) is the standard default. If you need time-ordered IDs for better database index locality, consider version 7 or an alternative like ULID.
Are UUIDs better than auto-increment integer IDs?
They excel when IDs must be generated without a central authority, merged across systems, or kept non-guessable. Integers are smaller, more readable, and index better, so the right choice depends on your needs.

Related tools

Related terms for UUID (Universally Unique Identifier)