UUID Generator
Generate v4 UUIDs
About This Calculator
A UUID (Universally Unique Identifier) is a 128-bit identifier formatted as 32 hex characters in groups of 8-4-4-4-12. Version 4 UUIDs are randomly generated, making collisions practically impossible — even generating a billion UUIDs per second for 100 years.
Formula
v4 format: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
x = random hex digit; y = 8, 9, a, or b (variant bits)
Probability of collision with 1 billion UUIDs ≈ 1 in 1 billion billion
Example Calculation
Example UUID v4
- Generate 122 random bits
- Set version bits to 0100 (4) and variant bits
- Format as 8-4-4-4-12 hex groups
550e8400-e29b-41d4-a716-446655440000
UUID Versions
| Version | Generation Method | Common Use Case |
|---|---|---|
| v1 | Time-based + MAC address | Distributed systems needing time ordering |
| v3 | MD5 hash of namespace+name | Deterministic IDs from known inputs |
| v4 | Random | General-purpose unique IDs (most common) |
| v5 | SHA-1 hash of namespace+name | Deterministic IDs (safer than v3) |
Frequently Asked Questions
Is it safe to use UUID as a primary key in a database?
Yes, but with trade-offs. UUIDs prevent ID enumeration attacks and work well in distributed systems. However, random v4 UUIDs cause index fragmentation. Consider UUID v7 (time-ordered) or sequential UUIDs for better database performance.
Are two UUIDs ever the same?
Theoretically possible but practically impossible. With v4 UUIDs, you would need to generate about 2.7 quintillion UUIDs before having even a 50% chance of one collision (the birthday paradox threshold).
What is the difference between UUID and GUID?
GUID (Globally Unique Identifier) is Microsoft's term for UUID. They follow the same RFC 4122 standard and are interchangeable. The terms are used in different technology ecosystems but refer to the same concept.