Skip to content
Agents tracked: 440 Downloads (7d): 202M down 19.5% GitHub stars: 10.4M Releases (7d): 607 Agent status: 3 with issuesSince last limit reset: Claude 28d · Codex 0d Updated Oct 21, 2026

Time-based UUIDs with uuid v7

A version 7 UUID starts with a Unix timestamp in milliseconds, so ids created later carry a later time.

All uuid examples uuid: usage and stats

Time-based UUIDs with uuid v7: screenshot of the example below running
The code below, running in Chromium on our server (Oct 12, 2026). Press Run to see it live and change it.

How it works

  1. Call v7(). Import v7 and call it five times. The example then sorts the strings and checks the sorted list against the order they were created in. [1]
  2. Set the time with msecs. The msecs option sets the timestamp field. The helper msFromV7 reads the first 12 hex digits back into a date, so you can see 2025-01-01 come back out. [1]
  3. Calls with and without options. The first five calls pass no options; the last one passes { msecs }. The README describes how the two cases are handled. [1]

Run and edit it

It runs in your browser, in a sandboxed frame that cannot see this site; the packages load from esm.sh only after you press Run.

import { v7 as uuidv7 } from 'uuid'

// Generate a few v7 UUIDs in a row
const ids = []
for (let i = 0; i < 5; i++) ids.push(uuidv7())
ids.forEach((id, i) => console.log(`v7 #${i + 1}:`, id))

// Sort the strings and compare with creation order
const sorted = [...ids].sort()
console.log('sorted order equals creation order:', sorted.every((id, i) => id === ids[i]))

// The first 12 hex digits hold the millisecond timestamp
const msFromV7 = (id) => parseInt(id.replace(/-/g, '').slice(0, 12), 16)
console.log('time in v7 #1:', new Date(msFromV7(ids[0])).toISOString())

// msecs option sets the timestamp field yourself
const fixed = uuidv7({ msecs: Date.UTC(2025, 0, 1) })
console.log('v7 for 2025-01-01:', fixed)
console.log('decoded back:', new Date(msFromV7(fixed)).toISOString())
Ctrl/⌘ + Enter runs

Free for signed-in members, with a daily limit. Describe the change in plain words; the new code runs only in your browser.

The decoded time of v7 #1 is the moment you ran the code; change the date in Date.UTC to move the fixed one. Code written by AgentGid [1].

Checked Oct 12, 2026: it starts without errors in Chromium with uuid 14.0.3. Needs WebGL.

More uuid examples

Random UUIDs with uuid v4 Name-based UUIDs with uuid v5 Validating UUIDs with uuid Converting UUIDs to bytes with uuid

Sources

  1. uuid README (GitHub)

Explanations written by AgentGid from the official docs; the numbers in brackets point here. The code marked "written by AgentGid" is ours and free to copy.

Building something with uuid? Ask AgentGid →