UUID v4 Generator
Generate unique identifiers instantly using cryptographically strong random values.
What is a UUID?
A UUID (Universally Unique Identifier), also known as GUID (Globally Unique Identifier), is a 128-bit identifier that is unique across space and time. UUIDs are used to identify information in computer systems without requiring a central registration authority.
With 2122 possible UUID v4 values, the probability of generating duplicate UUIDs is astronomically low—you'd need to generate 1 billion UUIDs per second for 85 years to have a 50% chance of a collision.
UUID Format Breakdown
Total: 32 hexadecimal digits (128 bits) separated by 4 hyphens = 36 characters
UUID Versions Explained
| Version | Generation Method | Use Case | Privacy |
|---|---|---|---|
| v1 | Timestamp + MAC address | Time-ordered IDs, logs | Leaks info |
| v3 | MD5 hash of namespace + name | Reproducible IDs from names | Deterministic |
| v4 | Cryptographically random | General purpose (most common) | Private |
| v5 | SHA-1 hash of namespace + name | Reproducible IDs (more secure than v3) | Deterministic |
| v7 | Unix timestamp + random | Sortable IDs for databases | Private |
Recommendation: Use UUID v4 for most applications. Use v7 if you need time-sortable IDs for database performance.
Common Use Cases
Replace auto-increment IDs with UUIDs for better security (no enumeration), distributed database compatibility, and easier data merging.
Generate unique IDs across multiple servers/services without coordination. Perfect for microservices and serverless architectures.
Generate unique file names for uploads to prevent collisions and avoid exposing sequential patterns.
Assign unique request IDs for tracing requests across services, debugging, and log correlation.
Frequently Asked Questions
UUID v1 vs v4: Which should I use?
Use UUID v4 in most cases. It's completely random and doesn't expose any information about when or where it was created.
Avoid UUID v1 unless you specifically need time-ordering. V1 UUIDs expose your MAC address and creation timestamp, which can be privacy/security concerns.
Are UUIDs truly unique?
UUIDs are practically unique, not mathematically guaranteed unique. UUID v4 has 122 random bits, giving 5.3 × 1036 possible values. The probability of collision is so astronomically small (1 in 2.7 quintillion for any two random UUIDs) that for all practical purposes, they can be treated as unique. You'd need to generate 103 trillion UUIDs to have a one-in-a-billion chance of a duplicate.
What does the UUID format mean?
A UUID like 550e8400-e29b-41d4-a716-446655440000
follows RFC 4122:
- 36 characters total (32 hex + 4 hyphens)
- The 13th character indicates version (4 = random)
- The 17th character (first after 3rd hyphen) is 8, 9, a, or b (variant indicator)
- Case-insensitive (though lowercase is conventional)
How do I generate UUIDs in code?
// JavaScript (modern browsers & Node.js) crypto.randomUUID() // Python import uuid str(uuid.uuid4()) // Java java.util.UUID.randomUUID() // C# / .NET Guid.NewGuid().ToString()
Should I use UUIDs or auto-increment IDs?
Use UUIDs when:
- Building distributed systems or microservices
- IDs are exposed in URLs (prevents enumeration attacks)
- Merging data from multiple sources
Use auto-increment when:
- Single database with no distribution needs
- Storage space is critical (UUID = 16 bytes vs 4-8 bytes)
- Need natural ordering by creation time