Skip to the content

UUID v7 Generator

Version 7 UUIDs start with the time they were made, so they sort in order of creation. One at a time or up to 1,000 in one go.

Kind

Starts with the time it was made, so newer ones sort after older ones.

 
Share this tool:TwitterFacebookLinkedInWhatsAppEmail

What is in a version 7 UUID

The time first, and randomness after it.

BitsWhereWhat it holds
48The first two groupsThe moment it was made: milliseconds since 1 January 1970, UTC
4The first digit of the third groupThe version: always 7
12The rest of the third groupRandom for the first UUID of a millisecond, counting up for the ones that follow
2Inside the first digit of the fourth groupThe variant, as in every standard UUID
62Everything after thatRandom

Because the time comes first, sorting version 7 UUIDs as plain text puts them in the order they were made. The 48 bits for the time are enough until the year 10889.

The 12 bits in the middle are where implementations differ. The standard lets them be random, a counter or a finer reading of the clock. Here they count up within a millisecond, so a thousand UUIDs made in one go still come out in order.

When to choose it

For primary keys. A database keeps its index sorted. Random keys such as version 4 scatter new rows all over that index, while version 7 keys arrive at the end, the way a counter would, without anybody having to hand out numbers. Inserts stay fast and recent rows stay close together.

Support has caught up: PostgreSQL has uuidv7() from version 18, Python has uuid.uuid7() from 3.14 and .NET has Guid.CreateVersion7() from version 9. The format itself was standardised in RFC 9562 in May 2024.

Do not choose it where the time of creation should stay private. Anybody who gets to see the UUID can read it, as the inspector above shows.

How likely is a duplicate?

Two version 7 UUIDs can only be equal if they were made in the same millisecond, and then they still have to agree on the 74 bits that follow the time. On this page that cannot happen, because the counter moves on with every UUID. Between separate machines it comes down to the random bits: if a million UUIDs were made in one and the same millisecond with all 74 of those bits random, the chance of a duplicate among them would be about 1 in 38 billion.

The other versions, the nil UUID and the inspector are explained on the UUID generator page.

See all 9