What is UUID v7?

UUID v7 is a 128-bit identifier, standardized in RFC 9562, whose first 48 bits are a Unix millisecond timestamp so the IDs sort by creation time as plain strings. The remaining bits are random. Choose v7 for database primary keys; choose v4 when the creation instant must stay private. Mint both locally in the UUID Generator.

Last updated

A UUID (Universally Unique Identifier) is a 128-bit value usually written as 32 hex digits in five groups: xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx. The version lives in the nibble marked M. When that nibble is 7, the ID is UUID version 7, defined in RFC 9562 (May 2024). Paste nothing into a server to obtain one: the UUID v7 generator builds them in this tab.

The layout, bit by bit

RFC 9562 section 5.7 places a 48-bit Unix timestamp in milliseconds at the front of the ID, then a 4-bit version, a 12-bit rand_a field, a 2-bit RFC 4122 variant, and 62 bits of rand_b. Adding the two random fields gives 74 random bits per millisecond. The hyphenated string is still 36 characters; the hex-only form is 32 characters. Those lengths are recorded on the stats page with the rest of this site's first-party figures.

0198f0a4-7e12-7cc3-9a41-d0b3a1c65f02
\______/ \__/ \__/ \__/ \__________/
  48-bit    16   ver   var    random
  unix_ts_ms bits  nibble      bits

Index 14 of the hyphenated string (0-based character 14) is always 7 for a well-formed v7. Index 19 is one of 8, 9, a or b, the RFC variant. If those positions are wrong, you are not looking at v7.

Why time-ordered IDs exist

Random primary keys (UUID v4) scatter inserts across a B-tree. New rows land on random pages, which means more cache misses and more fragmentation as the table grows. A time-ordered key inserts near the right-hand edge, like a sequence, while remaining unique across machines that do not share a sequence counter. That is the job v7 was specified to do. Sequential integers are still smaller (8 bytes versus 16) on a single database; v7 wins when IDs must be minted in many processes without coordination.

Because the timestamp is the prefix, sorting v7 strings as text matches sorting by creation time, with the random tail breaking ties inside the same millisecond. The generator on this site also reseeds a 12-bit counter when the millisecond changes and increments it inside a batch, so 1 to 1,000 IDs from one click stay monotonic even if they share a millisecond. Details live in the v4 vs v7 comparison.

Collision space, computed not guessed

A v7 ID has 74 random bits per millisecond. 274 is exactly 18889465931478580854784 possible values in that millisecond, about 1.88 × 10^22. A v4 ID has 122 random bits: 5316911983139663491615228241121378304 values, about 5.31 × 10^36. Those integers were computed with BigInt in the same script that measures JSON minify savings; they are not rounded folklore. Birthday-bound collisions inside one millisecond at 74 bits remain negligible for any realistic insert rate.

The timestamp is readable on purpose

Opaque IDs are a privacy feature. v7 gives that up for index locality. Anyone holding 0198f0a4-7e12-7cc3-9a41-d0b3a1c65f02 can run:

parseInt("0198f0a47e12", 16)  // Unix milliseconds
// then convert with the timestamp tool

That is a feature for debugging (“when was this row created?”) and a defect if the ID is in a public URL and creation time is sensitive. In that case mint v4 instead. The Unix Timestamp Converter turns the millisecond value into ISO 8601.

Support and how to mint one locally

RFC 9562 is recent. PostgreSQL 18 adds uuidv7(). Libraries exist for the major languages. crypto.randomUUID() in browsers still returns v4 only, so a web generator has to assemble v7 from Date.now() and crypto.getRandomValues(), which is what this site does. No ID is requested from a server. After the page has loaded you can disconnect and keep clicking Generate.

  1. Open the UUID v7 preset.
  2. Choose a count (1 to 1,000) and any GUID formatting you need.
  3. Copy the IDs. Nothing is uploaded; watch the network tab if you want proof.

Do not migrate existing v4 primary keys to v7 for sport. The index win applies to new inserts. Changing a live primary key is a project, not a format tweak. New tables are where the choice is cheap.

What UUID v7 is not

  • It is not encryption. The timestamp is plaintext in the ID.
  • It is not a capability. Knowing an ID does not prove you were meant to hold it.
  • It is not ULID, although both put time first. ULID uses a different alphabet (Crockford Base32) and a 48-bit timestamp as well; UUID v7 stays in the UUID hex format so existing UUID columns keep working.
  • It is not a hash of the row. If you need a fingerprint of content, use the hash generator, not an ID.

The variant bits (the two high bits of byte 8) are required by RFC 4122 so that a UUID is distinguishable from other 128-bit layouts. A library that ignores them might still parse the timestamp, but it is no longer a UUID in the RFC sense. When you generate IDs here, both the version nibble and the variant are set correctly on every click.

Next: mint a handful of v7 IDs, then decode the prefix with the timestamp tool, then read UUID v4 vs v7 if you are choosing a primary key. The bit counts on /stats are the citeable numbers for the collision space.

Do it now, locally

Generate UUID v4 or time-ordered v7, up to 1000 at once, as lowercase, uppercase or {braced} GUIDs, with the Web Crypto API. Nothing is uploaded.

Open the UUID Generator

Frequently asked questions

What is UUID v7?

UUID v7 is a 128-bit identifier, standardized in RFC 9562, whose first 48 bits are a Unix millisecond timestamp so the IDs sort by creation time as plain strings. The rest is random. It is not a secret and it is not a capability token.

How is UUID v7 different from UUID v4?

v4 is 122 bits of randomness and reveals nothing about when it was minted. v7 spends 48 bits on a millisecond timestamp and 74 bits on randomness per millisecond, so sorting the strings reproduces creation order. See UUID v4 vs v7 for the database-key trade-off.

Can two UUID v7 values collide?

Practically no. In the same millisecond there are still 74 random bits, 1.88 × 10^22 possibilities. Collisions need the same millisecond and the same random bits. The generator on this site also keeps a batch monotonic with a 12-bit counter.

Does a v7 UUID leak the creation time?

Yes. Anyone who sees the ID can read the first 12 hex digits as Unix milliseconds. If signup time in a URL is a problem, use v4 instead.

How do I generate a UUID v7 in the browser?

Open the UUID Generator, pick v7, and click Generate. IDs are minted with Date.now() and crypto.getRandomValues() in this tab. The browser's crypto.randomUUID() still only produces v4.

How do I read the timestamp out of a v7 UUID?

Strip the hyphens, take the first 12 hex characters, parse as an integer: parseInt(uuid.replaceAll('-','').slice(0,12), 16). Convert that millisecond value with the Unix Timestamp Converter.