UUID v6 is defined in RFC 9562 as a reordering of UUID v1’s timestamp fields that enables chronological sorting. It was created to solve one specific problem: UUID v1 is time-based but does not sort in time order because the timestamp fragments are stored in non-monotonic order. UUID v6 fixes that while keeping everything else about UUID v1 intact.

UUID v1 field order (non-sortable)

UUID v1 field layout (problematic order):
Bits  0–31:  time_low          (least significant 32 bits of timestamp)
Bits 32–47:  time_mid          (next 16 bits of timestamp)
Bits 48–59:  time_hi_ver       (most significant 12 bits + 4-bit version)
Bits 60–63:  version nibble    = 1
Bits 64–65:  variant           = 10 (RFC)
Bits 66–79:  clock_seq         (14-bit counter)
Bits 80–127: node              (48-bit MAC address or random)

Example: 6ba7b810-9dad-11d1-80b4-00c04fd430c8
         ↑time_low↑ ↑tmid↑ ↑hi↑
         Least significant bits are FIRST — does not sort chronologically!

UUID v6 field order (sortable)

UUID v6 field layout (correct time order):
Bits  0–47:  time_high_mid     (most significant 48 bits of timestamp — FIRST)
Bits 48–51:  version nibble    = 6
Bits 52–63:  time_low          (least significant 12 bits of timestamp)
Bits 64–65:  variant           = 10 (RFC)
Bits 66–79:  clock_seq         (14-bit counter)
Bits 80–127: node              (48-bit MAC address or random)

Example: 1ec9414c-232a-6b00-b3c8-9f6bdeced846
         ↑most sig time first↑
         Most significant timestamp bits are FIRST — sorts chronologically!

The only change from UUID v1: timestamp fragments are reordered so the most significant bits come first. The Gregorian epoch, clock sequence, and node field are unchanged.

UUID v6 vs UUID v7 comparison

PropertyUUID v6UUID v7
Timestamp epochGregorian (Oct 15, 1582)Unix (Jan 1, 1970)
Timestamp resolution100 nanoseconds1 millisecond
Random bits6274
SortableYesYes
UUID v1 compatibleYes (field layout preserved)No
RFC 9562 statusFor v1 migrationRecommended for new systems
Node fieldMAC address (privacy risk)None

See Node ID — UUID v1 MAC Address Field for the privacy implications of the node field.

Code examples

// JavaScript — uuidv6 package
import { v6 as uuidv6 } from 'uuid';

const id = uuidv6();
// '1ec9414c-232a-6b00-b3c8-9f6bdeced846'

// Version check
import { version } from 'uuid';
version(id); // 6

// Sort behavior — UUID v6 sorts chronologically
const ids = [uuidv6(), uuidv6(), uuidv6()];
ids.sort(); // Chronological order (like UUID v7)
# Python — uuid6 library
import uuid6

id = uuid6.uuid6()
# UUID('1ec9414c-232a-6b00-b3c8-9f6bdeced846')

print(id.version)  # 6
-- PostgreSQL — pg_uuidv7 extension provides uuid_generate_v6() too
CREATE EXTENSION IF NOT EXISTS pg_uuidv7;

SELECT uuid_generate_v6();
-- '1ec9414c-232a-6b00-b3c8-9f6bdeced846'

-- UUID v6 sorts chronologically in PostgreSQL uuid column
SELECT uuid_generate_v6() < uuid_generate_v6(); -- true

When to use UUID v6

Use UUID v6 when:

  1. Migrating from UUID v1 — your existing code parses UUID v1 fields (MAC address, clock sequence, Gregorian timestamp) and you need to preserve that structure
  2. UUID v1 consumers — external systems decode UUID v1 fields from your IDs and must continue working
  3. 100-nanosecond resolution — you need finer than millisecond precision (UUID v7 is millisecond)

Use UUID v7 instead when:

  1. Starting fresh — no UUID v1 compatibility required
  2. Simpler timestamp — Unix milliseconds are easier to work with than Gregorian 100-ns ticks
  3. More randomness — 74 bits vs 62 bits gives a wider collision safety margin

See UUID Version for the full version comparison.

Migration: UUID v1 → UUID v6

// Convert a UUID v1 to UUID v6 (reorder timestamp fields)
function v1ToV6(uuidV1: string): string {
  const hex = uuidV1.replace(/-/g, '');
  // v1 layout: time_low(8) + time_mid(4) + time_hi_ver(4) + rest(16)
  const timeLow = hex.slice(0, 8);
  const timeMid = hex.slice(8, 12);
  const timeHiVer = hex.slice(12, 16);
  const rest = hex.slice(16);

  // v6 layout: time_hi(6 of 8 from timeHiVer+timeMid+timeLow) + ver(1) + time_lo_12 + rest
  const timeHigh = timeHiVer.slice(1) + timeMid + timeLow.slice(0, 3);
  const timeLow12 = timeLow.slice(3, 6);
  const v6hex = timeHigh + '6' + timeLow12 + rest;

  return [
    v6hex.slice(0, 8), v6hex.slice(8, 12), v6hex.slice(12, 16),
    v6hex.slice(16, 20), v6hex.slice(20),
  ].join('-');
}

Frequently asked questions

What is the difference between UUID v6 and UUID v1?

UUID v1 stores its Gregorian timestamp in three fragments: time_low (32 bits), time_mid (16 bits), and time_high_and_version (12 bits) — in that order. This means UUID v1 values do NOT sort chronologically. UUID v6 places the most significant timestamp bits first: time_high, then time_mid, then time_low. The result sorts chronologically while using the same Gregorian epoch (100-nanosecond ticks since Oct 15, 1582) as UUID v1. See UUID Bit Fields.

Should I use UUID v6 or UUID v7 for new projects?

For new projects, prefer UUID v7. UUID v6 was designed as a migration path for systems already using UUID v1 — it keeps the Gregorian epoch and MAC address node field for backwards compatibility. UUID v7 uses a Unix millisecond timestamp (simpler, no epoch conversion) and 74 bits of randomness (more than v6's 62 bits). RFC 9562 recommends UUID v7 for new systems and UUID v6 only for UUID v1 compatibility. See UUID Version.

Is UUID v6 in RFC 9562?

Yes. RFC 9562 (which replaced RFC 4122 in 2024) formally defines UUID v6 as an official UUID version. UUID v6 was informally specified in draft form for years before RFC 9562. Its status is "for backward compatibility with UUID v1" — implementations that need to migrate from UUID v1 while gaining sort order should use v6; implementations starting fresh should use v7.