What is a UUID?
A UUID (Universally Unique Identifier) — also known as a GUID in the .NET world — is a 128-bit identifier defined by RFC 9562 (May 2024, replacing the 2005 RFC 4122). It identifies data — database rows, files, events, sessions, distributed messages — without needing a central coordinator. UUIDs are written as 36 characters: 32 hexadecimal digits in five hyphenated groups (8-4-4-4-12).
A typical UUID looks like 550e8400-e29b-41d4-a716-446655440000. The 13th character (the first character of the third group) encodes the version — which algorithm produced the UUID.
Pick the right UUID version
Six UUID versions are in active use today. Each has its own dedicated generator with code samples and a deeper explainer:
Quick UUID version cheat sheet
Generate a UUID in your code
Most modern languages have built-in UUID v4 generation — you usually don't need a third-party library:
// Browser & Node.js 19+
const id = crypto.randomUUID();
// → '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'import uuid
id = uuid.uuid4() # random (v4)
id = uuid.uuid7() # time-ordered (Python 3.13+)-- Postgres 13+
SELECT gen_random_uuid(); -- v4
-- Postgres 18+
SELECT uuidv7(); -- v7