When to use it
Seeding test rows, cache keys, throwaway session tokens. Under the
hood this hits crypto.randomUUID(), so on any modern platform the
output is cryptographically random.
v4 vs v7
- v4 — fully random. All 128 bits minus 6 version/variant bits are random. The common default.
- v7 — the first 48 bits are a Unix-millisecond timestamp, which makes them sortable in time order. Useful for database primary keys because inserts stay close together and indexes stay less fragmented. (RFC 9562, standardized in 2024.)
Formatting
- With hyphens — the canonical
xxxxxxxx-xxxx-…form. - No hyphens — Mongo ObjectID replacements, URL slugs.
{braces}— what legacy Windows GUID surfaces expect.- Uppercase — COM GUIDs, old .NET conventions.
The toggles compose, so you can combine "no hyphens + uppercase" for a 32-char compact form.
Where are the identifiers generated?
UUIDs are generated on the fly via the browser's crypto API. Nothing is sent or saved. Close the tab and they're gone.