UUID Version 7: The Future of Unique Identifiers Has Arrived

    July 1, 2024
    10 min read
    Technical explainer
    News
    uuid
    innovation
    distributed-systems
    best-practices

    UUIDs have long been the gold standard for global identifiers in distributed systems. But for years, we’ve had to choose between randomness (UUIDv4) and ordering (UUIDv1) — with trade-offs either way.

    Now, there's a new option: UUIDv7.

    It’s timestamp-based. It’s sort-friendly. And it’s finally standardized in [RFC 9562 (2024)](https://datatracker.ietf.org/doc/rfc9562/).

    Let’s explore how UUIDv7 works, why it matters, and how to use it today across multiple languages.


    🚀 What Is UUIDv7?

    UUIDv7 is designed to combine the best parts of UUIDv1 and UUIDv4:

    • Time-sortable like UUIDv1
    • Randomized and privacy-safe like UUIDv4
    • Compact (128 bits) and compatible with existing UUID parsers

    UUIDv7 Format (simplified):

    • 48 bits: Unix timestamp in milliseconds
    • 4 bits: Version (0111)
    • 74 bits: Random or entropy bits

    Result:

    • Chronologically sortable
    • Globally unique (with 74+ bits of entropy)
    • Safer than UUIDv1 (no MAC or clock leakage)

    🧠 Why UUIDv7 Matters

    FeatureUUIDv4UUIDv1UUIDv7
    Random❌ (time/MAC)✅ (74+ bits)
    Sortable
    Traceable⚠️ MAC leaks✅ Anonymized
    Standard-compliant✅ (RFC 9562)
    Ideal forAuth tokensLogs/eventsEvent IDs, DB PKs

    💻 Using UUIDv7 Across Languages

    🔹 JavaScript (Node.js)

    Use the uuidv7 package:

    bash
    npm install uuidv7
    js
    import { v7 as uuidv7 } from 'uuidv7';
    
    console.log(uuidv7());

    🔹 Python

    Install the uuid6 package:

    bash
    pip install uuid6
    python
    from uuid6 import uuid7
    
    print(uuid7())

    Or use ulid for a similar result with base32 encoding.

    🔹 Go

    Use github.com/oklog/ulid (or UUIDv7-native lib):

    go
    import (
        "fmt"
        "time"
        "github.com/oklog/ulid/v2"
        "math/rand"
    )
    
    func main() {
        entropy := ulid.Monotonic(rand.New(rand.NewSource(time.Now().UnixNano())), 0)
        id := ulid.MustNew(ulid.Timestamp(time.Now()), entropy)
        fmt.Println(id.String())
    }

    While ULID is not UUIDv7, it serves a similar function.

    🔹 Rust

    rust
    use uuid7::uuid7;
    
    fn main() {
        let id = uuid7();
        println!("UUIDv7: {}", id);
    }

    Install via:

    toml
    uuid7 = "0.7"

    🧪 Ideal Use Cases for UUIDv7

    • Primary keys in distributed SQL and NoSQL databases
    • Event identifiers in Kafka, Pulsar, or SQS
    • Log entries and trace IDs
    • Time-series storage, with ordering benefits
    • Systems that need to sort IDs by creation time

    ⚠️ Cautions and Considerations

    • UUIDv7 is new — some libraries or DBs may not fully support it yet
    • Be careful with time accuracy (ensure millisecond precision)
    • If you need base32 or lexicographic sortability, consider ULID

    🧰 Implementation Tips

    • Use a library — don't roll your own bit manipulation unless you know the spec
    • Store UUIDv7 in UUID or BINARY(16) columns — they're still 128-bit
    • Index by UUIDv7 for better locality in writes (vs UUIDv4)

    Final Thoughts

    UUIDv7 gives us the ordering of UUIDv1, the safety of UUIDv4, and a standardized format that works across modern systems.

    It’s not just an evolution — it’s a solution to long-standing trade-offs in distributed ID generation.

    🔧 If you’re building modern APIs, event systems, or scalable databases — the future is UUIDv7.

    Summary

    This article explores the new UUIDv7 standard — a timestamp-based, sortable, and high-entropy identifier. Learn how it works, why it matters, and how to implement UUIDv7 across multiple programming languages.

    TLDR;

    UUIDv7 is the next generation of identifiers — combining timestamp ordering with strong randomness.

    Key takeaways:

    • UUIDv7 is time-sortable, making it ideal for databases and event streams
    • It keeps 74+ bits of randomness for collision resistance
    • Libraries are now available in most modern languages (JS, Python, Go, Rust)

    Use UUIDv7 when you need both global uniqueness and temporal ordering — without sacrificing scale.

    Cookie Consent

    We use cookies to enhance your experience on our website. By accepting, you agree to the use of cookies in accordance with our Privacy Policy.