UUID v7 Generator
Generate time-ordered UUID v7 identifiers instantly — the modern standard for database primary keys, combining a Unix millisecond timestamp with random bits. Free, browser-only, no signup.
What Is It
UUID v7 Generator: What Is a UUID v7?
This UUID v7 generator produces the time-ordered UUID variant formally added in RFC 9562 (May 2024). Its first 48 bits encode the current Unix timestamp in milliseconds, and the remaining bits are filled with random data — giving you an identifier that is both globally unique and sortable by creation time.
This makes UUID v7 the recommended choice for new database primary keys in 2026: rows insert in roughly chronological order, keeping B-tree indexes compact instead of fragmenting the way random UUID v4 keys do at scale.
Anatomy
UUID v7 Format
A UUID v7 follows the standard 8-4-4-4-12 pattern, but the first 12 hex characters are not random — they directly encode a timestamp:
| Position | Value | Meaning |
|---|---|---|
| First 48 bits (12 hex chars) | Timestamp | Unix time in milliseconds |
| 13th character | 7 | Always the digit 7 — marks this as version 7 |
| 17th character | 8, 9, a, or b | Variant bits (RFC 9562 variant) |
| Remaining bits | Random hex | ~74 bits of randomness |
Example: 018f7a3c-1b2d-7e4f-a3c2-1234567890ab — the first section changes predictably over time, unlike v4.
Why It Matters
Why UUID v7 Is Replacing v4 for Database Keys
The core problem UUID v7 solves
B-tree indexes (used by PostgreSQL, MySQL, and most databases) perform best when new rows insert in roughly ascending order. Random UUID v4 keys scatter inserts across the entire index, causing page splits and bloat. UUID v7's timestamp prefix keeps new rows clustered together — matching the index performance of an auto-increment column while keeping UUID's distributed-generation benefits.
| UUID v4 | UUID v7 | |
|---|---|---|
| Sortable by time | No | Yes |
| Index performance at scale | Degrades (random inserts) | Stays efficient (sequential-ish) |
| Reveals creation time | No | Yes — by design |
| Best for | Tokens, secrets | Database primary keys |
Code
Generate a UUID v7 in Code
Need more languages? See our full code guides for JavaScript, PHP, Go, and more.
FAQ