What Is UUID v7 and Why Use It?

UUID Version 7 is a time-ordered identifier defined in draft RFC 4122 bis (RFC 9562). It encodes a 48-bit millisecond timestamp in the first part of the UUID and fills the rest with random data. The result is globally unique and sortable by creation time.

Why v7?

Version 4 UUIDs are random, so they don't sort well. Inserting many v4 IDs into a B-tree index causes fragmentation and slower writes. Version 1 is time-based but has a more complex layout and can leak timestamp and node info. Version 7 gives you time ordering with a simple, privacy-friendly design: the high bits are time, the rest are random.

Benefits

When to Use v7

Use v7 when you want primary keys or entity IDs that are unique and naturally ordered by time—e.g. events, logs, or any table where "newest first" queries are common. If you don't care about order, v4 remains the simplest choice. Generate v7 UUIDs with our generator, bulk tool, or API.

UUID v1 vs v4 vs v7 · UUID as primary key · Validator