Contents › § 7

UUID generator

Pick a version and how many you need. UUIDs are made with your browser’s secure random generator — nothing is fetched from a server.

§ 7.1v4 or v7?

v4v7
Made from122 random bits48-bit Unix time in ms + 74 random bits
Sort orderRandomRoughly by creation time
Database indexInserts land all over a B-treeInserts append near the end — friendlier to indexes
LeaksNothingWhen it was created

Use v7 for primary keys you’ll insert a lot of; use v4 when the creation time shouldn’t be guessable from the ID.

§ 7.2Reading a UUID

In xxxxxxxx-xxxx-Vxxx-Nxxx-xxxxxxxxxxxx, the digit at V is the version (4 or 7) and N is the variant — 8, 9, a or b for standard UUIDs. If V isn’t a digit you expect, the value wasn’t generated as that version.

§ 7.3Will two ever collide?

With 122 random bits, you would need to generate on the order of 2.7 × 1018 v4 UUIDs before the chance of a single duplicate reaches 50%. Collisions in practice come from bad random number generators, not from the math.

§ 7.QQuestions

Is crypto.randomUUID used?

For v4 we fill 16 bytes from crypto.getRandomValues and set the version and variant bits, which is what crypto.randomUUID does. v7 follows RFC 9562 §5.7 with a counter so IDs made in the same millisecond still sort in order.

Is a GUID the same as a UUID?

Yes — GUID is Microsoft’s name for the same 128-bit format.

§ 7.RReferences

Last reviewed 2026-10-14.