UUID v4 Generator
Generate random UUIDs (v4) in bulk, using the browser’s cryptographic random source — never Math.random.
UUID v4
What makes a v4 UUID unique
A v4 UUID is 122 random bits, with six bits fixed to mark the version and variant. There is no counter, no timestamp and no machine identity involved — uniqueness comes purely from the size of the space.
That space is large enough that collisions are not a practical concern: you would need to generate about 2.7 × 10¹⁸ UUIDs before the chance of a single collision reaches one in a billion.
The randomness here comes from crypto.getRandomValues. Generators built on Math.random produce values that look random but are predictable from a handful of samples — which matters the moment a UUID is used as a session token or an unguessable URL.
When another version fits better
- v7 — when the id becomes a database primary key. Random v4 values scatter inserts across a B-tree index; v7 sorts by time and keeps them together.
- v5 — when the same input must always yield the same id, such as deriving an id from a URL.
- ULID — when a human has to read, type or dictate the value.
Frequently asked questions
Are these UUIDs safe to use as secret tokens?
They are generated from a cryptographic source, so they are unpredictable. Even so, a purpose-built token with a defined length and expiry is a better fit than a UUID for authentication.
Do I need to worry about duplicates?
No. With 122 random bits, generating a billion UUIDs per second for a century still leaves the collision probability negligible.
Are the UUIDs generated on your server?
No. They are generated in your browser and never transmitted, so the same value never exists anywhere else.