UUID Generator

UUID Generator

Generate UUID v1, v4, v7 universally unique identifiers. Bulk UUID generation and validation. Free online GUID/UUID generator for developers

UUIDs solve the "two services need to assign IDs without coordinating" problem. The catch is that not all UUID versions are interchangeable — v4 is random, v7 is sortable by time, v1 is time-based but leaks the MAC address that generated it. Pick the wrong version and you either kill your index performance or expose information you did not mean to. This generator produces v1, v4, and v7 in bulk with the bit layout visible so you can verify what you are using.

The version that matters most: v4 vs v7

UUID v4 is 122 random bits with 6 bits of fixed version/variant metadata. Collisions are astronomically improbable but the IDs have no temporal order — inserting them as a primary key into a B-tree index causes random I/O across the entire tree, which slows down write-heavy workloads on tables with many millions of rows.

UUID v7 (RFC 9562, 2024) fixes this by prefixing 48 bits of millisecond Unix timestamp before 74 bits of randomness. Sorting v7 UUIDs by their string value yields rough chronological order, which means new rows insert into the rightmost leaf of a B-tree — the same access pattern as auto-increment integers, without the coordination problem.

Working example: byte layout

Input

Generated v7 UUID

Output

01919b8e-3f4f-7a31-b8d2-1c4f8b9c0e1a

Breakdown:
  01919b8e-3f4f  → 48-bit timestamp (Unix ms)
  7              → version (v7)
  a31            → 12 random bits
  b              → variant (10xx)
  8d2-1c4f8b9c0e1a → 62 random bits

The first 13 hex chars (52 bits, 48 timestamp + 4 version) are monotonic per millisecond, so two UUIDs generated 1ms apart sort correctly. Within a single millisecond, the random tail breaks ties.

Which version to pick

  • v4 — default for client-side IDs, opaque identifiers, share links. Never sorts, but you do not care because the UUID is not your primary key.
  • v7 — default for database primary keys when you cannot use auto-increment integers (distributed systems, multi-master replication, sharded tables). Indexes behave like sequential inserts.
  • v1 — historical, leaks the MAC address of the generator and a timestamp. Useful for forensics, useless for everything else. Avoid unless you have a specific reason.
  • v6 — re-ordered v1 that sorts correctly. Superseded by v7 in practice; only use if you need MAC-address linkage AND sortability simultaneously, which is rare.
  • v3, v5 — namespace-based (hash a name within a namespace). Use these when you want the same input to always yield the same UUID (deterministic IDs from URLs, for instance).

When to reach for this tool

  • You need a one-off test ID and your project does not have a generator imported yet.
  • You are evaluating whether to migrate from v4 to v7 for primary keys and want to inspect the bit layout before committing.
  • You are filling a fixtures file with 50 sample IDs and want them to look realistic without writing a script.
  • You are debugging a UUID parsing issue and need to confirm the variant/version nibbles are what you expect.

What this tool will not do

  • It will not generate ULIDs, KSUIDs, NanoIDs, or other competing schemes. UUID v7 covers most use cases those were designed for. If you specifically need a 26-character Crockford base32 string (ULID) for URL aesthetics, use a dedicated tool.
  • It will not coordinate with your database. UUIDs are unique by probability, not by uniqueness check — collisions across 100 billion generated v4 UUIDs have probability around 10^-18.
  • It will not check your existing data for collisions. For a one-off audit, just SELECT id, COUNT(*) FROM your_table GROUP BY id HAVING COUNT(*) > 1.

Random bits come from window.crypto.getRandomValues — the same CSPRNG your TLS connection uses. Not from Math.random, which is predictable from a small sample of outputs.

Frequently asked questions

Are UUIDs truly unique?

Not strictly. v4 has 122 random bits, so the probability of a collision among 2.7 quintillion (2.7×10^18) UUIDs is about 50%. In practice, you will hit other problems first. v7 inherits the same property after the timestamp prefix.

Why are my UUID primary keys destroying database performance?

Because random UUIDs (v4) cause writes to land in random pages of a B-tree index, which thrashes the buffer cache. Switch to v7, which is timestamp-prefixed and inserts sequentially. PostgreSQL since v18 has built-in uuidv7() functions; for older versions, generate v7 in your application layer.

How is UUID v7 different from ULID?

Both are timestamp-prefixed with random suffixes. ULID uses Crockford base32 (26 chars, no dashes), UUID v7 uses standard hex format (36 chars with dashes). Sort order is identical in both. Pick UUID v7 for ecosystem compatibility, ULID for URL/display aesthetics.

Can I store a UUID more efficiently than 36 characters?

Yes. UUIDs are 128 bits = 16 bytes. Use BINARY(16) in MySQL or the native UUID type in PostgreSQL. The 36-character hyphenated string form is for humans, not databases.

Is using UUID v4 for session tokens secure?

Adequate but not ideal. 122 random bits is enough that brute-forcing the token space is infeasible. However, session tokens benefit from being shorter and faster to validate. For greenfield work, use a 256-bit random token formatted as base64url; for existing v4-based systems, the security is fine in practice.

What is the difference between UUID and GUID?

Nothing in practice. GUID is Microsoft's name for the same thing. The byte layout, version semantics, and string format are identical. Windows code says GUID, Unix code says UUID, and the spec is RFC 9562.

Related tools

Published · Updated · E-Utils editorial team