What is UUID? Complete Guide with Examples

3 min readsecurity

A UUID (Universally Unique Identifier) is a 128-bit identifier formatted as 32 hexadecimal digits in five groups separated by hyphens (e.g., 550e8400-e29b-41d4-a716-446655440000). UUIDs can be generated independently by any system without coordination, yet are statistically guaranteed to be unique. They're widely used as database primary keys, API identifiers, distributed system correlation IDs, and anywhere unique identifiers are needed without a central authority.

Try It Yourself

Use our free UUID Generator to experiment with uuid (universally unique identifier).

How Does UUID (Universally Unique Identifier) Work?

UUID generation varies by version: v1 uses the MAC address and timestamp (sortable but reveals machine identity), v4 uses 122 bits of random data (most common, maximum randomness), and v7 (newest) encodes a Unix timestamp in the high bits with random data in the low bits (sortable + random). The 128-bit space provides 2¹²² possible v4 UUIDs — you'd need to generate 1 billion UUIDs per second for 86 years before a 50% chance of one collision.

Key Features

  • Multiple UUID versions: v1 (timestamp), v4 (random), v7 (timestamp + random, sortable)
  • 128-bit identifiers with negligible collision probability across all systems worldwide
  • No coordination needed — any system can independently generate globally unique IDs
  • Standard format recognized across all programming languages and databases
  • Batch generation for bulk ID creation in data migration and testing scenarios

Common Use Cases

Database Primary Keys

UUIDs as primary keys enable independent ID generation by application servers without database round-trips, essential in distributed systems and microservice architectures.

API Resource Identifiers

Public APIs use UUIDs instead of sequential IDs to prevent enumeration attacks (guessing valid IDs by incrementing) and to hide information about resource creation order and total count.

Distributed System Correlation

Microservices assign UUID correlation IDs to requests at the entry point. This ID propagates through all downstream services, enabling end-to-end request tracing across distributed systems.

Frequently Asked Questions

Related Guides

Related Tools