uuid-generator · v4
1
6d94646b-5f4e-4635-94c0-3db1ea1f2e50About UUID Generator
A UUID (Universally Unique Identifier) is a 128-bit identifier formatted as 32 hexadecimal characters in the pattern xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx. UUID v4, the most commonly used variant, is generated from random numbers — making collisions statistically impossible even across distributed systems.
This generator uses the Web Crypto API's crypto.randomUUID() function, which is cryptographically secure and built into every modern browser and Node.js 15+. No server required, no tracking, no stored history.
UUIDs are used as primary keys in databases (avoiding sequential ID guessing attacks), unique filenames for uploaded assets, session and correlation IDs in distributed systems, idempotency keys in payment APIs, and identifiers in REST APIs where the client generates the ID before the server confirms it.
Generate a single UUID or bulk-generate up to 20 at once for seeding databases or test fixtures. Each click generates fresh, fully random values. Copy individual UUIDs or copy all at once.
How it works
Each identifier comes from crypto.randomUUID(), a method on the Web Crypto API. Under the hood it draws 16 random bytes from the operating system's cryptographically secure random number generator (CSPRNG) — the same entropy source used for TLS session keys — so the values are not the predictable pseudo-random output of Math.random().
The specification then overwrites a few specific bits to make the value a valid version-4 UUID: the four bits that identify the version are set to 0100 (which is why the third group always starts with a 4), and the top bits of the variant field are set so the fourth group begins with 8, 9, a, or b. The remaining 122 bits stay fully random. Finally the 16 bytes are formatted as 32 lowercase hex characters with hyphens in the 8-4-4-4-12 pattern. Bulk generation simply calls the same function in a loop, and nothing is stored between clicks.
Frequently Asked Questions
What is a UUID v4? ▾
UUID v4 is a 128-bit random identifier following the format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx. The "4" indicates version 4 (random). The y position is either 8, 9, a, or b to indicate the variant. All other characters are cryptographically random hex digits.
Are UUIDs truly unique? Can they collide? ▾
Collisions are theoretically possible but practically impossible. UUID v4 has 2^122 possible values (~5.3 × 10^36). If you generated 1 billion UUIDs per second for 100 years, the probability of a single collision would be about 50%. For real-world use, treat them as unique.
Should I use UUID as a database primary key? ▾
It depends. UUIDs are globally unique and safe to generate client-side, but they're larger than integers (16 bytes vs 4–8 bytes), random UUIDs fragment indexes in MySQL/PostgreSQL, and they're harder to read in logs. UUID v7 (time-ordered) solves the index fragmentation issue. For most apps, UUIDs are fine.
What's the difference between UUID v1, v4, and v7? ▾
UUID v1 encodes the MAC address and timestamp — sortable but exposes hardware info. UUID v4 is fully random — the most common choice. UUID v7 (newer) encodes a millisecond timestamp prefix, making it sortable like v1 but without hardware exposure — ideal for database primary keys.
Is crypto.randomUUID() safe to use in production? ▾
Yes. crypto.randomUUID() uses the operating system's cryptographically secure random number generator (CSPRNG) — the same source used for TLS keys and password hashing. It's available in all modern browsers, Node.js 15+, and Deno.