What Is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit identifier formatted as 32 hex digits in 5 groups: 550e8400-e29b-41d4-a716-446655440000. There are ~3.4×1038 possible UUIDs. The format follows an 8-4-4-4-12 pattern separated by hyphens. UUIDs can be generated without a central authority and are virtually guaranteed to be unique.
UUID Anatomy
550e8400-e29b-41d4-a716-446655440000
|------| |--| |--| |--| |----------|
time- time ver var node
low mid +hi (random)
The 13th hex digit indicates the version (4 in this example). The 17th hex digit indicates the variant (8, 9, a, or b for standard UUIDs).
UUID Versions
| Version | Source | Use Case |
|---|---|---|
| v1 | Timestamp + MAC | Legacy systems |
| v4 | 122 random bits | General purpose (most popular) |
| v5 | Namespace + SHA-1 | Deterministic from name |
| v7 | Timestamp + random | Database keys (sortable) |
Generate a UUID
JavaScript
crypto.randomUUID();
// "3b241101-e2bb-4d67-8b73-2a5c64f19f44"
Python
import uuid
str(uuid.uuid4())
# '3b241101-e2bb-4d67-8b73-2a5c64f19f44'
Bash
uuidgen
# 3B241101-E2BB-4D67-8B73-2A5C64F19F44
Try It Yourself
Generate UUIDs with our UUID Generator, UUID v4, or UUID v7 tools.
Frequently Asked Questions
Can UUIDs collide?
The probability is astronomically low. For UUIDv4, you would need ~2.7 quintillion (2.7 × 1018) UUIDs for a 50% collision chance. In practice, collisions do not happen.
UUID vs GUID: what is the difference?
They are the same thing. GUID (Globally Unique Identifier) is Microsoft's term for UUID. The format and generation algorithms are identical.
Should I use UUID or auto-increment for database keys?
UUIDs are better for distributed systems (no coordination needed). Auto-increment is simpler and more efficient for single-database applications. UUIDv7 is a good compromise: globally unique and time-sorted for good index performance.