How to Generate UUIDs (v4 and v7) and Pick the Right Version

By Alok Singh · Published

UUIDs feel like a solved problem until you choose one for a primary key and your database index starts bloating, or until someone asks whether a GUID is the same thing. UUID generator makes v4 or v7 UUIDs in bulk, in whatever format you need, and decodes any UUID you paste.

Steps

  1. Pick version 4 or version 7.
  2. Choose how many and the format.
  3. Press Generate, then copy or download.

Formats include standard lowercase, uppercase, no hyphens, and braces (the Windows GUID style).

v4 or v7?

Version 4 is 122 random bits from your browser's cryptographically secure generator (crypto.getRandomValues). It reveals nothing about when or where it was made. That's the right choice for public-facing IDs, invite tokens or anything where leaking creation time is a concern.

Version 7 starts with the current Unix time in milliseconds, followed by random bits. Because they sort by creation time, new rows go to the end of a B-tree index instead of random locations. That keeps indexes compact and inserts fast in PostgreSQL, MySQL and similar databases. For database primary keys, v7 is the better default today.

Both follow RFC 9562, the 2024 standard that replaced RFC 4122.

The checker

Paste any UUID and the page shows its version and variant, and for version 7 and version 1 it decodes the creation time. Useful when debugging: "when was this record created?" can be answered from a v7 ID alone, even if the created_at column is missing.

That's also the privacy trade-off: if you use v7 in public URLs, anyone can read when each object was created.

Collisions

People worry about this more than they need to. With 122 random bits, you'd need to generate billions of v4 UUIDs per second for many years before a collision became likely. The real risks are bugs: copying the same ID twice in a test fixture, or using a non-cryptographic random function in some library.

GUID vs UUID

Same thing. GUID is Microsoft's name for the 128-bit format. If you're pasting into a Windows registry file, C# code or SQL Server, the braces format gives you {...} style.

Example uses

Tips

When not to use a UUID

For small internal tables, an auto-incrementing integer is simpler, smaller and perfectly fine. UUIDs shine when IDs are created in many places at once (multiple servers, mobile apps offline, data merged from different systems) or when you don't want sequential IDs exposing how many orders or users you have. Choose them for those reasons, not by default.

Privacy

The page says UUIDs are generated inside the page and stay on your device. Like every page on the site, it carries Google ads.

FAQ

Can two UUIDs be the same? In practice, no.

v4 or v7 for database keys? v7, because it sorts by time and keeps indexes compact.

Is a GUID a UUID? Yes, same format; use the braces option for Windows style.

How random are they? They come from crypto.getRandomValues, the browser's secure generator.

Need IDs? Generate them with UUID generator.

— Alok Kumar Singh


← All guides