Generate UUID v7 with timestamp analysis. Part of the DevTools Surf developer suite. Browse more tools in the Generators collection.
Use Cases
Generate time-sortable primary keys for a PostgreSQL or MySQL table without a separate created_at column.
Create correlation IDs for distributed tracing that sort chronologically when displayed in logs.
Replace random UUID v4 with v7 in a system where sortable IDs would improve query performance.
Generate IDs for an event store where chronological ordering of IDs is required.
Tips
UUID v7 is sortable by generation time when treated as a binary value or hex string — use it as a database primary key to maintain insert-order clustering without a separate created_at column.
The timestamp precision in UUID v7 is millisecond-level (first 48 bits) — two UUIDs generated within the same millisecond on the same generator may have the same timestamp prefix.
UUID v7 is defined in RFC 9562 (2024) — verify your language runtime's UUID library version supports v7 before using it in production.
Fun Facts
UUID v7 was added to RFC 9562, which replaced RFC 4122 in May 2024 — making it one of the most recent standardized ID formats. RFC 4122 (the previous UUID standard) was published in 2005.
The main design goal of UUID v7 was sortability by creation time — a property that dramatically improves database index performance compared to random UUIDs (v4), which cause random-order B-tree insertions.
GitHub switched their internal ID generation from sequential integers to a Snowflake-like format in 2011. UUID v7 provides a standards-based alternative to proprietary Snowflake IDs for new projects.
FAQ
Should I use UUID v4 or v7 for database primary keys?
UUID v7 for new tables — the timestamp prefix means sequential inserts are ordered in the B-tree index, avoiding the random page splits that make UUID v4 primary keys slow on large tables. v4 is fine for lookup keys that are never used for range queries.
Is UUID v7 globally unique?
Yes — the 74 random bits (beyond the 48-bit timestamp and 6-bit version/variant fields) provide more than enough collision resistance. The probability of collision between two v7 UUIDs generated in the same millisecond is approximately 1 in 10^22.