UUID Guide: Version 4 IDs for Databases and APIs
Written by Muhammad Ali · Senior Full Stack Software Engineer
Personal website: codedbymali.comUUID guide covering why v4 IDs are popular, collision probability in practice, and how to generate RFC-compliant UUIDs in the browser for tests and prototypes.
A UUID (Universally Unique Identifier) is a 128-bit value usually shown as 36 hex characters with hyphens. Version 4 UUIDs are mostly random and work well when many writers need IDs without a central counter — microservices, client-generated keys, and distributed databases.
Collision risk for v4 is negligible for typical application volumes. Still, databases should enforce uniqueness constraints. Prefer UUIDs when you need merge-friendly identifiers; prefer sequential IDs when locality and index locality matter more than decentralization.
UUID v7 (time-ordered) improves index locality compared with random v4 while remaining unique. Choose v4 for maximum simplicity and broad library support; consider v7 when write-heavy primary keys benefit from roughly sorted inserts.
Generate IDs locally when seeding fixtures, writing docs, or debugging without installing a CLI. EverydayDevTools UUID Generator creates RFC-style v4 values in the browser using secure randomness when available.
Open UUID Generator