Open tools · 0

About

UUID v7 Generator

A version 7 UUID is ready as the window opens: its first 48 bits are the time in milliseconds, so IDs made later sort later, as text and as bytes. Make one or a thousand, copy them as lines, a JSON array or an SQL list, and paste any v7 into Inspect to read when it was made.

What it does

  • RFC 9562’s layout: 48 bits of Unix milliseconds, the version digit 7, a 12-bit counter, the variant, and 62 random bits.
  • The counter keeps IDs from one millisecond in order: a thousand made at once still sort as they were made.
  • The counter starts low enough to leave room for 2,048 more IDs, so a batch never runs out within a millisecond.
  • The standard, no-hyphen and upper-case forms keep the time order as text; the 22-character Base64URL form does not.
  • Inspect reads a v7 back to the time it was made, in UTC and to the millisecond.
  • Within a batch a clock that steps back is not followed, so no ID sorts before the one made ahead of it.

How to use it

  1. Set how many, from one to a thousand.
  2. Pick the form: standard, no hyphens, braces, URN or Base64URL.
  3. Copy them, or download them as lines, a JSON array or an SQL list.
  4. Paste a v7 into Inspect to read the time it was made.

What it does not do

  • Hiding when a record was made: the time is in the ID for anyone to read, so IDs shown to the public may be better as version 4.
  • Order between machines: each orders its own IDs, and two clocks a few milliseconds apart interleave theirs.

Questions

Why use version 7 for a primary key?

New keys land at the end of the index instead of at random places in it, so a B-tree index stays compact and an insert touches fewer pages. Version 4 keys scatter the writes across the whole index as the table grows.

Can I read the time inside a UUID v7?

Yes. The first 12 hex digits are the milliseconds since 1970: paste the UUID into Inspect and the time appears in UTC. One that starts 018bcfe5-6800 was made on 14 November 2023 at 22:13:20 UTC.

Is a UUID v7 as unique as a v4?

Close to it. Each carries 62 random bits, and its counter starts at a random value, and two IDs can only clash when they share a millisecond. A v4 has 122 random bits and no time at all.

Do databases sort them by time?

A native uuid column compares the bytes in order, and so does a text column holding the standard form, so both sort by time. SQL Server’s uniqueidentifier is the exception: it compares the last six bytes first.

Everything here runs in your browser. Nothing you type, paste or open is uploaded, and there is no account and no queue. How that works.

Often used with

More in Generators

  • Password Generator: Generate strong random passwords, memorable passphrases and PINs in your browser, with the real entropy in bits and the time to crack.
  • QR Code Generator: Make QR codes for links, Wi-Fi, contacts, email, SMS and events: static codes that never expire, with colours, a logo, and PNG or SVG download.

All toolsAbout utilbrewPrivacy