UUID generator

Version 4 and version 7 UUIDs, plus nanoid-style short tokens, in bulk.

aca31c81-81d1-4f87-8416-30e84a0f2ca5
c6ca04c8-0fef-4a37-be8d-ff2668b65ce3
5925a87c-01cb-4ecc-aebc-2b760fae9cfd
5ecdf4ca-0ee4-40c6-b47e-e2721cd505fb
6783c2dc-5f20-4cd2-a4cb-0035d79e1e00
21ff681d-eb15-43ab-81a8-a8671d23eb95
a6c5f8ec-bc92-4330-a644-c0615d755aa3
0e126a9b-8d70-4a48-845a-aec71b8a1543
25a2563c-d447-4353-8bc1-cd10fa947efc
903f3ee9-3493-4a9b-9399-70cf86b95c76

How it works

All of these are generated with crypto.getRandomValues, the browser's cryptographically secure random source — not Math.random, which is predictable and unsuitable for identifiers that must not be guessable.

v4 versus v7

A v4 UUID is 122 bits of randomness. Excellent for uniqueness, terrible as a database primary key: consecutive inserts land at random positions in the B-tree index, causing page splits and poor cache locality.

v7 (standardised in RFC 9562, 2024) puts a 48-bit millisecond timestamp in the leading bits, so new IDs sort after old ones and inserts append to the end of the index. It keeps 74 bits of randomness — still far more than enough — and is the better default for new systems. The trade-off is that it leaks creation time.

Collision odds

Generating a billion v4 UUIDs a second for a century gives roughly a 50% chance of one collision. In practice, uniqueness is not the thing to worry about.

ULID and nanoid

ULID is 26 Crockford-base32 characters, lexicographically sortable by time, with no ambiguous characters (no I, L, O or U). nanoid is 21 URL-safe characters with collision resistance comparable to a UUID in 40% less space — useful for short public URLs.

Do not use UUIDs as secrets

A v4 UUID is unguessable, but a v1 or v7 one is not — the timestamp is right there in the value. For session tokens, API keys and password-reset links, use the secure token option, which is 256 bits from the CSPRNG with no structure at all.