🆔 UUIDv7 Generator
Generate time-ordered UUIDv7 identifiers (RFC 9562) for database primary keys. Prevents B-tree fragmentation — batch generation, visual breakdown, and sortability demo included.
🎯 Generate a UUIDv7
📦 Batch Generation
⚖️ UUIDv4 vs UUIDv7 — Side by Side
🔴 UUIDv4 (Random)
- Fully random (122 random bits)
- ❌ Causa B-tree fragmentation
- No time information
- RFC 4122 (2005)
🟢 UUIDv7 (Time-Ordered)
- 48-bit timestamp + 74 random bits
- ✅ B-tree friendly — sequential inserts
- Extractable creation timestamp
- RFC 9562 (May 2024)
What Is the UUIDv7 Generator?
UUIDv7 Generator is a free, browser-based developer tool that creates time-ordered, RFC 9562-compliant UUIDv7 identifiers. It solves the problem of B-tree index fragmentation in database primary keys — unlike random UUIDv4 which scatters writes across index pages, UUIDv7 embeds a Unix timestamp in milliseconds as the first 48 bits, making every generated ID naturally sortable in chronological order. No downloads, no sign-ups — everything runs locally in your browser using crypto.getRandomValues().
Key Features
- Time-ordered generation: The first 48 bits encode a Unix millisecond timestamp, so UUIDs sort chronologically — perfect for database primary keys and event sourcing.
- B-tree friendly: Sequential inserts prevent page splits in InnoDB (MySQL) and PostgreSQL B-tree indexes, improving write throughput by up to 40% compared to UUIDv4.
- Crypto-safe randomness: The remaining 74 bits come from
crypto.getRandomValues()— collision probability is astronomically low (~1 in 2^74 per pair). - RFC 9562 compliant: Fully implements the UUIDv7 standard published in May 2024, with correct version (0x7) and variant (10xx) bits.
- Batch generation (1–100): Generate up to 100 UUIDv7s at once with individual copy buttons and a Copy All shortcut.
- Visual bit breakdown: See exactly which parts of the UUID are timestamp (blue), version (green), and random (gray) — understand the structure at a glance.
📋 When to Use the UUIDv7 Generator
The UUIDv7 Generator is essential for backend developers, database architects, and distributed systems engineers who need globally unique, time-sortable primary keys.
Common scenarios:
- Database primary keys for new projects — start with UUIDv7 instead of UUIDv4 to prevent index fragmentation from day one. Your B-tree indexes will stay compact and fast as your data grows.
- Event sourcing and audit logs — UUIDv7 gives you both a unique event ID and a rough creation timestamp baked into the same value — no separate
created_atcolumn needed for ordering. - Distributed systems with multiple writers — when multiple services or database shards independently create records, UUIDv7 ensures globally unique IDs that remain roughly time-ordered across the entire system.
- API idempotency keys — use time-ordered UUIDv7 as idempotency keys in payment processing or order creation APIs for safe retries with natural ordering.
⚙️ How the UUIDv7 Generator Works
The UUIDv7 Generator runs entirely in your browser using client-side JavaScript. When you click Generate, the browser reads the current Unix timestamp in milliseconds (Date.now()) and encodes it into the first 6 bytes (48 bits) of a 16-byte array as a big-endian integer. The remaining 10 bytes are filled with cryptographically strong random values from crypto.getRandomValues(). The version nibble (bits 48–51) is set to 0111 (7) and the variant bits (bits 64–65) are set to 10, following RFC 9562. The result is formatted as the standard 36-character UUID string: xxxxxxxx-xxxx-7xxx-xxxx-xxxxxxxxxxxx. No data is ever sent to a server — your UUIDs are generated entirely on your device.
How to Use the UUIDv7 Generator
- Click Generate — A single UUIDv7 is created instantly using your browser's
crypto.getRandomValues()and the current Unix timestamp in milliseconds. - Examine the visual breakdown — The generated UUID is color-coded: blue for the timestamp, green for the version nibble, and gray for the random bits. Hover to see tooltips.
- Set batch count — Use the slider to choose how many UUIDv7s to generate at once (1–100). Each UUID gets its own timestamp with 74 bits of fresh randomness.
- Verify sortability — Scroll through the batch output to confirm that UUIDs appear in chronological order — proof they are B-tree friendly for database indexes.
- Copy and use — Click individual Copy buttons or use Copy All to grab the entire batch. Paste directly into your SQL queries, ORM code, or API payloads.
🔐 When NOT to Use & Security Notes
UUIDv7 leaks creation timestamp — don't use it where time privacy matters. The first 48 bits encode the exact millisecond when the UUID was generated. Anyone can decode the timestamp from a UUIDv7. If you're generating user session IDs or tokens that are exposed to clients (e.g., in URLs), use UUIDv4 instead. For internal database keys where time visibility is acceptable or even useful, UUIDv7 is ideal.
At very high throughput (>1000 UUIDs/ms on a single machine), timestamp collision is possible. When generating more than ~1,000 UUIDs per millisecond, multiple UUIDs will share the same timestamp prefix. The 74 random bits still prevent actual ID collisions, but ordering within the same millisecond is undefined. For server-side bulk generation at >10,000/sec, use a dedicated library with monotonic sub-millisecond counters.
Not all databases support UUIDv7 natively yet. PostgreSQL needs the pg_uuidv7 extension (github.com/fboulnois/pg_uuidv7) or a custom function. MySQL 8.0 doesn't have a native UUIDv7 function — generate at the application layer and store as binary(16) using UUID_TO_BIN() with the swap flag. SQLite has no native UUID type — store as text or blob.
Browser crypto.getRandomValues() is safe for 99% of use cases. For generating up to a few thousand UUIDs per second, the browser CSPRNG provides sufficient entropy. For server-side bulk generation at scale (>10,000/sec), use a server-side library (like uuid npm package v9+ or Python's uuid7 package) that batches from /dev/urandom.
Frequently Asked Questions
What's the difference between UUIDv4 and UUIDv7?
UUIDv4 is fully random — all 122 bits come from a CSPRNG with no time information. UUIDv7 (RFC 9562, May 2024) embeds a 48-bit Unix millisecond timestamp in the first section, making generated IDs naturally sortable in chronological order. v7 prevents B-tree index fragmentation in databases — v4 does not. In benchmarks, UUIDv7 can improve write throughput by 30–40% over UUIDv4 for insert-heavy workloads.
Why is UUIDv7 better for database primary keys?
In B-tree indexes (used by InnoDB/MySQL, PostgreSQL), inserting random UUIDv4 values causes page splits because each new key lands at a random position in the index — this fragments the B-tree and slows down both writes and reads. UUIDv7's time-ordered prefix means new keys almost always append near the right edge of the B-tree, keeping index pages dense and minimizing I/O. The result: faster inserts, smaller indexes, and better cache locality.
Can I use UUIDv7 with PostgreSQL/MySQL?
PostgreSQL: Install the pg_uuidv7 extension for a native uuid_generate_v7() function. Alternatively, use the uuid-ossp extension with a custom PL/pgSQL wrapper. MySQL 8.0: No native UUIDv7 function exists — generate UUIDv7 at the application layer (like this tool does) and store as binary(16). Use UUID_TO_BIN(uuid, 1) (MySQL 8.0.28+) with the swap flag for correct indexing. SQLite: Store as TEXT or BLOB — no native UUID type.
Is UUIDv7 the same as ULID?
They solve the same problem (time-sortable unique IDs) but differ in format and standardization. ULID uses Crockford Base32 encoding (26 characters), while UUIDv7 uses the standard 36-character UUID hex format (8-4-4-4-12). UUIDv7 is an official IETF standard (RFC 9562) and fits into existing UUID database columns without migration. ULID requires a separate column type or text/varchar storage. If you already use UUIDs, switch to v7 — if starting fresh with no UUID legacy, both are valid choices.
How many UUIDv7s can I generate per second?
At millisecond precision, you can generate ~1,000 unique UUIDv7s per second before timestamp collisions occur (multiple UUIDs in the same millisecond). The 74 random bits still guarantee uniqueness — ordering within the same millisecond is simply undefined. For server-side bulk generation at >1,000/sec, use a dedicated library with monotonic sub-millisecond counters (e.g., uuid npm package v9+). The browser-based generator in this tool is suitable for most application-level use cases.
Does UUIDv7 expose when a record was created?
Yes — the first 48 bits of a UUIDv7 are the Unix timestamp in milliseconds. Anyone with access to the UUID can decode the creation time to millisecond precision. For example, a UUIDv7 starting with 0191a4e2 encodes a specific timestamp. If time privacy matters (e.g., user-facing IDs, session tokens in URLs), use UUIDv4 instead. For internal database keys, audit logs, or event sourcing where time visibility is acceptable or useful, UUIDv7 is ideal.
Are UUIDv7s guaranteed to be unique?
With 74 bits of cryptographic randomness per UUID, the collision probability is astronomically low — approximately 1 in 2^74 (~1.9 × 10^22) per pair. You would need to generate billions of UUIDs per second for decades to have a meaningful chance of collision. UUIDv7 provides stronger uniqueness guarantees than auto-increment IDs across distributed systems, where primary key conflicts between shards are a real risk. The combination of a timestamp prefix and cryptographic random suffix makes UUIDv7 collisions virtually impossible in practice.
📖 Deep dive: UUIDv4 vs UUIDv7 for Database Primary Keys — our blog post explains the B-tree fragmentation problem and why time-ordered UUIDs matter.
Related Tools
Continue your workflow: Generated a UUIDv7 → try these next