What is UUID?
UUID (Universally Unique Identifier) is a 128-bit identifier that is guaranteed to be unique across all space and time. UUIDs are represented as 32 hexadecimal digits, displayed in five groups separated by hyphens (8-4-4-4-12 format).
Quick Facts
| Full Name | Universally Unique Identifier |
|---|---|
| Created | 1980s (standardized in RFC 4122 in 2005) |
| Specification | Official Specification |
How UUID Works
UUIDs are generated using algorithms that combine various sources of uniqueness such as timestamps, random numbers, and hardware addresses. There are several versions: Version 1 uses timestamp and MAC address, Version 4 uses random numbers (most common), Version 5 uses namespace and name with SHA-1 hashing. The probability of generating duplicate UUIDs is so low that it's considered practically impossible. UUIDs are widely used in distributed systems where unique identifiers are needed without central coordination.
Key Characteristics
- 128-bit length providing 2^128 possible values
- Standardized format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- Multiple versions for different use cases (v1, v4, v5, etc.)
- Can be generated without central authority
- Collision probability is negligible for practical purposes
- Case-insensitive (uppercase and lowercase are equivalent)
Common Use Cases
- Database primary keys in distributed systems
- Session identifiers in web applications
- File and resource naming
- Transaction IDs in microservices
- Device identification
Example
UUID v4 (Random):
550e8400-e29b-41d4-a716-446655440000
UUID v1 (Timestamp):
6ba7b810-9dad-11d1-80b4-00c04fd430c8
NIL UUID (all zeros):
00000000-0000-0000-0000-000000000000