UUID v7 Generator — Time-Ordered UUIDs for Database Primary Keys
Generate UUID v7 identifiers online (RFC 9562). The first 48 bits encode a Unix millisecond timestamp, so v7 UUIDs sort lexicographically by creation time — dramatically better as a database primary key than v4. Bulk generate up to 1000 and inspect the embedded timestamp for each. 100% local.
Last updated:
CommentsUUID v7 (RFC 9562, published May 2024) embeds a millisecond Unix timestamp in the first 48 bits, followed by 74 random bits. Values sort lexicographically by creation time — making them a much better fit for database primary keys than UUID v4. Need pure-random UUIDs instead? Use the UUID Generator.
| UUID v7 | Embedded timestamp | |
|---|---|---|
| 019f88a4-0a32-74f3-8811-33d040bfdbff | 2026-07-22 07:04:39Z | |
| 019f88a4-0a32-7062-bf18-aec2d9290bf9 | 2026-07-22 07:04:39Z | |
| 019f88a4-0a32-71dd-86c4-089ee1d78606 | 2026-07-22 07:04:39Z | |
| 019f88a4-0a32-7134-a25e-4e972d8873ba | 2026-07-22 07:04:39Z | |
| 019f88a4-0a33-7059-9089-d1c4b54fb67a | 2026-07-22 07:04:39Z |
Frequently Asked Questions
What makes UUID v7 different from v4?
UUID v4 is fully random — its 122 bits of entropy are great for uniqueness but terrible for database indexes. Every INSERT lands at a random spot in the B-tree, causing page splits and cache misses. UUID v7 (RFC 9562) puts a 48-bit Unix millisecond timestamp in the first bits, followed by 74 random bits. Result: values generated close in time are close in the sort order too — the index stays hot, INSERTs stay cheap.
Is UUID v7 a real standard?
Yes. UUID v7 was standardized in RFC 9562 (May 2024), which superseded RFC 4122 and introduced v6 / v7 / v8. Before that, teams used various homegrown formats (KSUID, ULID, Twitter Snowflake) to get the same time-ordering benefits. v7 is now the interoperable, standards-track answer.
Should I use v7 instead of v4 in Postgres / MySQL / SQL Server?
Almost always yes, if UUID v7 support exists in your driver. Postgres 18 has native uuidv7(); before that, most driver libraries (uuid npm, uuid-utils in Python, uuidgen in Java) generate v7 already. In MySQL and SQL Server, use v7 UUIDs and store them BINARY(16) for locality. The write throughput / index bloat improvements over v4 are dramatic on large tables.
Can I recover the timestamp from a v7 UUID?
Yes — this tool does it in the table above. Take the first 12 hex chars (48 bits) of the UUID, parse as an integer, treat as Unix milliseconds. In code: `new Date(parseInt(uuid.replaceAll('-','').slice(0,12), 16))`. That's when the UUID was minted, useful for debugging and time-range queries without extra columns.
Are v7 UUIDs cryptographically secure?
The random bits (74 of them) come from crypto.getRandomValues, a cryptographically secure PRNG. But you should NOT use UUID v7 as a security token — the timestamp is guessable and 74 bits of entropy is less than v4's 122. Use them for IDs you're happy publishing, not for password reset tokens or session cookies.
Related Tools
UUID Generator
Generate random UUIDs (v4) and time-ordered UUIDs (v7) online. Bulk generate up to 1000 at once and copy with one click.
NanoID
Generate NanoID strings online — 21 characters, URL-safe alphabet (a-Z, 0-9, -, _), same collision safety as UUID v4 in 40% less space. Bulk generate up to 1000 with custom length. 100% local.
ULID
Generate ULID (Universally Unique Lexicographically Sortable Identifier) strings — 26 characters, 48-bit millisecond timestamp + 80-bit randomness, Crockford Base32. Bulk generate up to 1000. 100% local.
CUID2
Generate CUID2 strings online — a modern, secure, collision-resistant ID format designed for horizontal scale and safe use in URLs, cookies, and databases. 100% local, no dependencies.
Snowflake ID
Generate Twitter Snowflake IDs online — 64-bit integers with 41-bit timestamp, 10-bit worker ID, 12-bit sequence. Preview and inspect how Snowflake IDs are structured. 100% local.
KSUID
Generate KSUID strings online — 27-character Base62, 32-bit UTC timestamp + 128-bit randomness. Time-sortable, human-typeable, no delimiters. Designed by Segment for high-volume event streams. 100% local.