plain/devtools home

UUID v4 vs UUID v7 vs ULID

All three are 128-bit identifiers you can create without asking a database. They differ in one thing that matters a lot: whether newer IDs sort after older ones.

Last reviewed 2026-10-21. Bit layouts are from RFC 9562 (May 2024) and the ULID specification. Database effects are described qualitatively; benchmark with your own data.

uuid-generatorsamplesCtrl↵ run · s sample · c copy

Inspect an ID

never leaves your browser

The short answer

Use UUID v7 for new database keys when you want IDs that sort by creation time. Use UUID v4 when you want nothing derived from time, such as tokens that should reveal nothing. Use ULID if you want a shorter, URL-friendly text form and your tooling already supports it.

RFC 9562, published in May 2024, replaced RFC 4122 and defined UUID version 7, which puts a 48-bit Unix timestamp in milliseconds at the front. The same RFC notes that time-ordered UUIDs have better database-index locality than random ones.

Side by side

ItemUUID v4UUID v7ULID
Defined inRFC 9562, section 5.4RFC 9562, section 5.7ulid/spec on GitHub (community specification)
Total size128 bits128 bits128 bits
Random bits1227480
TimestampNone48-bit Unix time in milliseconds48-bit time in milliseconds
Text form36 characters, hex with hyphens36 characters, hex with hyphens26 characters, Crockford Base32
Sorts by creation timeNoYes, as bytes or as textYes, as text (order within one millisecond is not guaranteed unless you use the monotonic mode)
Reveals creation timeNoYes, to the millisecondYes, to the millisecond
Database index behaviorRandom inserts, poor localityMostly appends, good localityMostly appends, good locality

Random bits for v4 and v7 are the figures in RFC 9562 (v7: 12 + 62 bits after the version and variant). ULID is 10 timestamp characters and 16 randomness characters.

Reading a UUID v7

The first 48 bits of a v7 UUID are a Unix timestamp in milliseconds. For example, the constructed value 018bcfe5-6800-7000-8000-000000000000 starts with 018bcfe5-6800, which is 1700000000000 milliseconds, or 2023-11-14T22:13:20.000Z. The remaining bits hold the version (7), the variant, and random data. This example is built by this page's code to show the layout; it is not a real identifier.

That timestamp is the privacy cost. Anyone who sees a v7 ID can tell when it was created. RFC 9562 notes that timestamps in a UUID are a small attack surface, so avoid v7 where creation time must stay secret.

Picking one

  • Primary keys in a table that is mostly inserted and read recently: v7 or ULID.
  • Public identifiers that should not leak order or timing, such as invite tokens: v4 (and for secrets, a purpose-built token, not a UUID).
  • IDs shown to people or put in short URLs: ULID is 26 characters rather than 36.
  • Existing systems that already store v4: keep them; mixing versions is allowed because they share one format.

Frequently asked questions

Is UUID v7 standardized?

Yes. RFC 9562, published in May 2024, defines versions 6, 7 and 8 and obsoletes RFC 4122.

Can I sort UUID v7 values as strings?

Yes, because the timestamp is the most significant part and the hex text is fixed width and lowercase or uppercase consistently. IDs created in the same millisecond order by their random bits unless your generator adds a counter.

Is ULID an RFC?

No. ULID is a community specification published on GitHub. It predates UUID v7 and solves the same sorting problem with a shorter text form.

Are UUID v4 collisions a practical concern?

With 122 random bits from a good random source, accidental collisions are not a practical concern at normal scale. The risk comes from a weak random number generator, not the format.

Sources

Related

esc
↑↓ move↵ open? all shortcuts

Keyboard shortcuts

Cmd or Ctrl shortcuts always work.
Everywhere
Everywhere
Open the command palette
CtrlK
Open the palette (outside a text field)
/
Show these shortcuts
?
Toggle light and dark theme
t
Go home
gh
Go to all tools
gt
On a tool page
On a tool page
Run the main action
Ctrl↵
Copy the output
c
Load the next sample
s
Focus the input
i
Leave a text field
Esc
Previous or next tool
[]
In the palette
In the palette
Move the selection
↑↓
Open the selected item
↵
Close
Esc