UUID v7 Generator
Press c to copy or r for a new one
Generate in bulk
What is UUID v7?
v7 was standardised in RFC 9562. It puts a 48-bit Unix millisecond timestamp at the front, then the version and variant bits, then 74 bits of randomness.
Because the timestamp comes first and is big-endian, sorting v7s as strings or as bytes sorts them by creation time. No extra column, no separate index.
Why it is usually the right default
Inserting time-ordered keys appends to the right edge of a B-tree instead of scattering across it, so a v7 primary key avoids the page splits and cache misses a v4 key causes on a large table.
74 random bits is fewer than v4's 122, but a collision would require generating two IDs with identical randomness inside the same millisecond. v7 remains collision resistant in practice.
The cost is the same as any sortable ID: creation time is public, and IDs issued near each other are partly guessable.
Querying a table by time
Once v7 is your primary key you no longer need a created_at index to ask for a week of rows. Every v7 minted in that week falls inside a single contiguous range, so a BETWEEN on the key column does the work.
The v7 time range tool gives you those bounds. Pick a start and an end, and it hands back the smallest and largest v7 that can exist between them, ready to paste into a query.
Generate one in code
TypeScript
import { v7 as uuidv7 } from "uuid";
uuidv7();Python
import uuid # uuid7 requires Python 3.14
uuid.uuid7()Go
import "github.com/google/uuid"
id, err := uuid.NewV7()Rust
// uuid = { version = "1", features = ["v7"] }
use uuid::Uuid;
Uuid::now_v7();SQL (Postgres)
-- uuidv7() is built in from Postgres 18.
SELECT uuidv7();What is a UUID?
A UUID is a Universally Unique IDentifier: a 128-bit number used to identify something without coordinating with anyone else. It is usually written as 32 hexadecimal characters in five hyphenated groups.
UUIDs come in several versions. v4 is random, v1 and v6 encode a timestamp and a MAC address, v3 and v5 hash a name inside a namespace, and v7 encodes a Unix millisecond timestamp followed by random bits.
Why use UUIDs?
UUIDs can be generated anywhere, by anyone, with no central authority, and still be safely assumed not to collide. That makes them useful for distributed systems, offline clients, and merging data from separate databases.
They are also instantly recognisable, which makes them easy to pick out of logs.
Some databases (for example Postgres) store a UUID as a 128-bit integer rather than a 36-character string, so using one as a primary key costs far less than it looks.
What are the downsides?
Uniqueness is probabilistic, not guaranteed. The odds of two v4 UUIDs colliding are negligible, but they are not zero.
Some versions leak information. A v1 or v6 UUID contains the MAC address of the machine that generated it and the moment it was generated, which is enough to correlate a device across systems. You can see exactly what a UUID gives away with the UUID decoder.
Time-ordered IDs are also partly guessable, so they are a poor choice for anything that doubles as a secret, such as a password reset token.