toolready. UUID Generator

UUID Generator

Generate UUID v4 or v7 — one at a time or in bulk.

UUID v4 vs v7

  • v4 — random — 122 bits of randomness. Globally unique, but unordered. The classic UUID.
  • v7 — time-ordered — the first 48 bits are a Unix millisecond timestamp, the rest is random. Sorts lexicographically by creation time, which makes it kinder to database indexes (B-trees love sortable keys).

When to use each

Use v4 when uniqueness is all you need and you don't care about ordering — session tokens, request IDs, anonymous user IDs.

Use v7 for primary keys in databases. The temporal ordering means new rows are appended near the end of the index instead of scattered randomly, which dramatically improves insert performance and cache locality.

Format options

  • lowercase — the canonical form (RFC 9562).
  • UPPERCASE — some legacy systems (older Microsoft APIs).
  • No hyphens — 32-char compact form, useful in URLs.
  • {Braces} — the Windows registry / GUID style.

How random is it?

Generation uses the browser's crypto.getRandomValues / crypto.randomUUID, which are cryptographically secure (CSPRNG). Same primitive Node.js, Go, and Rust use for the same job. Suitable for identifiers, session tokens, and any place where unpredictability matters.

Are UUIDs guaranteed to be unique?

Not guaranteed — but the collision odds are so astronomically small they're safe to treat as unique in practice. A v4 UUID has 122 random bits. You'd need to generate roughly 2.7 quintillion of them before the probability of a single collision reaches even 50% (the birthday-paradox threshold). At a billion UUIDs per second, that's on the order of a century. For any normal application, treat them as unique.

What happened to UUID v1, v3, and v5?

  • v1 — timestamp + MAC address. Sortable, but leaks the generating machine's hardware address and creation time. v7 is the modern, privacy-safe replacement.
  • v3 / v5 — deterministic hashes of a namespace + name (v3 uses MD5, v5 uses SHA-1). The same input always yields the same UUID — useful when you need a stable ID derived from existing data.

Can I use a UUID as a database primary key?

Yes, and it's common — but pick the right version. Random v4 keys scatter inserts across the index and fragment B-trees, hurting write performance at scale. v7 keys are time-ordered, so new rows append near the end of the index like an auto-increment integer would, while still being globally unique and safe to generate on the client. For new schemas that want UUID keys, v7 is the better default.