ToolsCourt
BlogUUID v4 vs v7: Which Should You Use in 2025?
Dev7 min read·January 2025

UUID v4 vs v7: Which Should You Use in 2025?

RFC 9562 standardised UUID v7 in 2024. Here is when to use each version, why v7 is better for databases, and how to generate both.

Try the free tool
No signup. Runs in your browser. Takes 10 seconds.
Open UUID Generator

The Short Answer

  • UUID v4 — use for general IDs, public-facing tokens, anything where randomness and unpredictability matter
  • UUID v7 — use for database primary keys in new applications (better index performance)

What Changed with RFC 9562 (May 2024)

RFC 9562 replaced RFC 4122 as the UUID standard in May 2024. It officially standardised UUID versions 6, 7, and 8, which were previously informal proposals. UUID v7 is now the recommended format for database primary keys going forward.

UUID v4 vs v7 — Side by Side

PropertyUUID v4UUID v7
Randomness122 random bits74 random bits
Time sortableNoYes (ms precision)
DB index performancePoor (fragmentation)Excellent (sequential)
Reveals creation timeNoYes
RFC standardRFC 4122 (2005)RFC 9562 (2024)
Browser/Node supportNative (crypto.randomUUID)Library needed

The Database Performance Difference

With UUID v4, each new record inserts into a random position in your primary key index. At 10 million+ rows, this causes page splits and fragmentation that slows inserts by 30–70%. UUID v7's timestamp prefix means every new record appends to the end of the index — the same efficient pattern as auto-increment integers, without the coordination overhead.

How to Generate UUID v7

// JavaScript (using uuid library)
import { v7 as uuidv7 } from 'uuid';
const id = uuidv7();

// Python
import uuid_utils  # pip install uuid-utils
id = str(uuid_utils.uuid7())

// Go
import "github.com/google/uuid"
id, _ := uuid.NewV7()
💡 The ToolsCourt UUID Generator supports both v4 and v7, generating RFC 9562-compliant UUIDs in your browser. No library needed for quick generation.
Ready to try it?
Free, instant, no signup required.
Open UUID Generator Free →