UUID v7 Generator
Create time-ordered version 7 UUIDs that sort by creation time, ideal for database primary keys.
Generate Time-Ordered UUID v7
UUID v7 combines the best of two worlds: it is unique without coordination like a random UUID, and it sorts by creation time like an auto-increment ID. That makes it the version most databases and ORMs now recommend for primary keys.
This page opens the UUID Generator with version 7 selected. The first 48 bits come from your clock; the rest come from the browser's secure random generator.
Why ordering matters for databases
Most relational databases store primary keys in a B-tree. A random v4 key lands somewhere in the middle of the index on every insert, forcing page splits and scattering related rows across the disk. A v7 key is almost always larger than the previous one, so new rows are appended at the end, just as with an integer sequence. On tables with millions of rows the difference in insert speed and index size is significant.
v4, v7 and ULID compared
| UUID v4 | UUID v7 | ULID | |
|---|---|---|---|
| Sortable by time | No | Yes | Yes |
| Random bits | 122 | 74 | 80 |
| Standard | RFC 9562 | RFC 9562 | Community spec |
| Fits a UUID column | Yes | Yes | Needs conversion |
| Reveals creation time | No | Yes | Yes |
Reading the timestamp back
Paste a v7 UUID into the inspector below the generator and it decodes the embedded time. You can do the same by hand: the first 12 hex digits, without the hyphen, are the milliseconds since 1970. For 01926f3a-7c2b-7d4e-… that is 0x01926f3a7c2b = 1728442956843, which is 9 October 2024 at 03:02:36.843 UTC.
UUID v7 in code
- PostgreSQL 18+:
uuidv7() - Python 3.14+:
uuid.uuid7() - Java: the
uuid-creatorlibrary,UuidCreator.getTimeOrderedEpoch() - Node.js: the
uuidpackage,import { v7 } from 'uuid' - .NET 9+:
Guid.CreateVersion7()
When time ordering does not matter, UUID v4 reveals less. If you need Microsoft-style formatting, see the GUID Generator.