· Igor Ilic

UUID generation: understanding UUID versions and when to use each

What is a UUID?

A universally unique identifier (UUID) is a 128-bit label standardized by RFC 4122. The canonical format is 32 hexadecimal digits displayed in five groups:

550e8400-e29b-41d4-a716-446655440000

UUIDs are designed to be unique across space and time without requiring a central registry.

UUID versions compared

VersionGeneration methodBest for
v4RandomGeneral-purpose primary keys, tokens
v7Time-ordered + randomDatabase indexes, time-sorted IDs
v1MAC address + timestampLegacy systems (privacy concerns)
v5Namespace + SHA-1Deterministic IDs from names

Why UUID v7 is gaining popularity

UUID v4 values are randomly distributed, which causes index fragmentation in databases like MySQL and PostgreSQL. UUID v7 embeds a millisecond timestamp prefix, so new IDs are sequential. This reduces page splits in B-tree indexes and improves insert performance.

Many modern frameworks and databases are adopting v7 as the default UUID format.

Generate UUIDs online

The UUID generator creates v4 and v7 UUIDs instantly. It also supports bulk generation and multiple output formats.