UUID versions at a glance
| Version | Built from | Typical use |
|---|---|---|
| v1 | Timestamp + MAC address | Legacy systems; leaks host identity |
| v4 | 122 random bits | General-purpose unique IDs, tokens, file names |
| v5 | SHA-1 hash of namespace + name | Deterministic IDs for the same input |
| v7 | Unix ms timestamp + random bits | Database primary keys, event IDs, logs (RFC 9562) |
Generating UUIDs in code
// JavaScript (browser & Node 19+)
crypto.randomUUID();
# Python
import uuid; uuid.uuid4()
-- PostgreSQL 13+
SELECT gen_random_uuid(); -- v4
SELECT uuidv7(); -- v7, PostgreSQL 18+
# Linux shell
cat /proc/sys/kernel/random/uuid
uuidgen Frequently asked questions
UUID v4 or v7 — which should I use?
Use v7 for database primary keys: it starts with a millisecond timestamp, so new IDs are roughly sorted and B-tree indexes stay compact. Use v4 when you want IDs that reveal nothing about creation time.
Are these UUIDs really random and unique?
Yes. Random bits come from the browser’s cryptographically secure generator (crypto.getRandomValues). A v4 UUID has 122 random bits, so a collision is practically impossible.
Is a GUID the same as a UUID?
Yes. GUID is Microsoft’s name for the same 128-bit identifier. Use the Uppercase and Braces options to get the {XXXXXXXX-…} style common in Windows and .NET.
Can I generate UUIDs offline?
Yes. Generation happens entirely in your browser, nothing is requested from a server.