UUID · 48-bit Unix milliseconds

UUID v7

A 48-bit Unix millisecond timestamp followed by random bits, for sortable identifiers.

Key facts

Timestamp48-bit Unix milliseconds
Random bitsAbout 74
OrderingLexicographic by creation time
StandardRFC 9562 (2024)
LifetimeMillisecond field good for about 10,000 years
OptionalMonotonic counter for same-millisecond generation

Time first, randomness after

The first 48 bits are a big-endian millisecond timestamp, so string order matches creation order. The remaining bits are random, with a few fixed for version and variant. Two IDs created in the same millisecond are ordered by their random tail unless the generator uses a monotonic counter.

Better index behavior

Because new values append near the end of the key space, v7 inserts behave like sequential keys: fewer page splits and better cache locality. The timestamp is visible to anyone holding the ID, so do not use v7 where creation time is sensitive.

Frequently asked questions

Is v7 always sortable?

Sortable by the millisecond timestamp. Within the same millisecond, ordering depends on the random tail or the implementation's counter.

Does v7 leak information?

Yes, the creation time in milliseconds is readable. Treat it as public metadata.

Can I use v7 as a database key?

Yes, and it is usually a better fit than v4 for append-heavy tables because inserts stay local to the end of the index.

New tools, straight to your inbox

One short email when we add tools worth using. No spam, unsubscribe anytime.