1001Ferramentas
🆔Generators

UUID v7 Generator

Generate UUID v7 — time-ordered UUIDs (48-bit timestamp ms + random). Ideal as primary key in databases. Everything in your browser.

UUID v7: the time-ordered UUID

UUID version 7 was standardised in RFC 9562 in May 2024, the successor to RFC 4122. It keeps the same 128-bit footprint and the familiar 8-4-4-4-12 hexadecimal layout as UUID v4, but the first half of the value is no longer random — it carries a Unix millisecond timestamp, so newer IDs sort after older ones.

Bit layout

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           unix_ts_ms                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          unix_ts_ms           |  ver  |       rand_a          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|var|                        rand_b                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            rand_b                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

That is 48 bits of unix_ts_ms, 4 bits of version (0111 = 7), 12 bits of rand_a (random or sub-millisecond entropy), 2 bits of variant, and 62 bits of rand_b. Total entropy after the timestamp: 74 random bits — comfortably collision-resistant.

Why use v7 over v4

Random UUIDs scatter writes across the entire index, so each insert touches a cold page. Time-ordered UUIDs append to the rightmost leaf — fewer page splits, better cache locality, smaller WAL volume. Published Postgres benchmarks show v7 inserts roughly 40% faster than v4 on tables with tens of millions of rows. Debugging is easier too: you can read the creation time straight out of the prefix.

The UUID version family

  • v1 — timestamp + MAC address. Leaks hardware identity.
  • v3 / v5 — deterministic, derived from namespace + name (MD5 / SHA-1).
  • v4 — random. The golden standard before v7.
  • v6 — v1 rebuilt for lexicographic sort.
  • v7 — millisecond timestamp + randomness. Recommended for new IDs.
  • v8 — fully custom layout, vendor-defined.

Watch out for clock skew

In distributed systems, two nodes generating in the same millisecond can produce IDs that are very close but not strictly monotonic. RFC 9562 suggests two mitigations: keep a monotonic per-process counter, or fill rand_a with sub-millisecond entropy so collisions inside a tick are still resolved by sort order.

FAQ

Can I migrate from v4 to v7 in the same column? Yes — they are both 128-bit UUIDs and share the same wire format. PostgreSQL's uuid type accepts both without any change.

Is v7 globally unique? Yes, with overwhelming probability. The 74 random bits make collisions inside the same millisecond astronomically rare.

Can I recover the timestamp? Yes — take the first 12 hex digits, parse as a 48-bit integer, and read it as Unix milliseconds.

Related Tools

Generate time-sortable v7 UUIDs

For anyone working with databases, the v7 UUID is the natural successor to the unique identifier. It stores a timestamp right at the start, so the IDs come out already ordered by creation time. This tool generates valid v7 UUIDs on demand.

The edge over the fully random v4 jumps out when you use it as a primary key. Because v7 grows in sequence over time, database indexes stay much leaner, without the scattering v4 causes. You combine the UUID's uniqueness with the ordering of an auto-increment.

Generation leans on the browser's randomness and runs locally, sending no identifier to any server. Generate a single one or several at once, then copy them.