What is UUID v7?
UUID version 7 is a time-ordered 128-bit identifier (36-char string) proposed in the new UUID specification draft. It consists of:
- Unix timestamp: 48 bits of millisecond precision Unix time
- Random data: 74 bits of random data
- Version and variant bits: 6 bits for format identification
Format example: 017f22e2-79b0-7cc3-98c4-dc0c0c07398f
How UUID v7 works
- Get current Unix timestamp in milliseconds (48 bits)
- Generate 74 bits of cryptographically strong random data
- Set version bits to 0111 (version 7)
- Set variant bits to 10 (RFC 4122 standard)
- Assemble as 32 hex digits with hyphens: 8-4-4-4-12 format
Advantages & Considerations
Advantages | Considerations |
---|---|
|
|
UUID v7 Structure
Bits | Content |
---|---|
0-47 | Unix timestamp (milliseconds) |
48-51 | Version (0111 for v7) |
52-63 | Random data |
64-65 | Variant (10 for RFC4122) |
66-127 | Random data |
UUID v7 vs. other versions
Version | Based on | Use case | Privacy |
---|---|---|---|
UUID v1 | Time + MAC | Time-ordered IDs | ⚠️ Reveals MAC |
UUID v3 | Namespace + MD5 | Deterministic IDs | ✅ Private |
UUID v4 | Random | Secure random IDs | ✅ Private |
UUID v5 | Namespace + SHA-1 | Deterministic IDs | ✅ Private |
UUID v6 | Time (reordered) | Sortable IDs | ⚠️ Reveals MAC |
UUID v7 | Time + random | Sortable IDs | ✅ Private |
Common Use Cases
- Database primary keys: Efficient indexes
- Distributed systems: Time-ordered without coordination
- Modern applications: Privacy-focused identifiers
- Microservices: Sortable cross-service IDs
- Event sourcing: Chronological event IDs
- Data warehousing: Time-ordered analytics IDs
Frequently Asked Questions
What's the advantage of UUID v7 over v1 or v6?
UUID v7 uses Unix timestamp milliseconds and random data rather than MAC addresses, offering privacy protection while maintaining sortability by generation time.
Is UUID v7 an official standard?
UUID v7 is currently a draft specification in the proposed RFC 4122bis document. It's not yet an official RFC standard but is implemented in many UUID libraries.
Can I extract the creation time from UUID v7?
Yes. The Unix timestamp in milliseconds can be extracted from the first 48 bits and converted to a standard datetime.
Are UUIDs v7 sortable by creation time?
Yes. UUID v7 is designed to be lexicographically sortable, with the Unix timestamp in the most significant bits, allowing direct string comparison to match chronological order.
Does UUID v7 expose any system information?
No. Unlike v1/v6, UUID v7 does not use MAC addresses. It combines timestamp with random data, protecting privacy while maintaining sortability.