RevealTheme logo

UUID Generator

Generate v4 UUIDs (random universally unique identifiers). Each click produces a new one.

What is a UUID and why does software use them?

A UUID (Universally Unique Identifier, sometimes called GUID in Microsoft contexts) is a 128-bit value used to identify entities without requiring coordination between systems. The point of a UUID is that two different programs, running on two different machines, with no knowledge of each other, can each generate UUIDs and confidently assume they'll never collide. That property unlocks distributed systems design: you can let any service mint IDs locally without a central counter, you can merge databases without renumbering rows, and you can pre-generate IDs on the client before the server even sees the request. UUIDs come in five canonical versions defined by RFC 4122: v1 (time + MAC address based, leaks creation time and machine identity), v3 (MD5 hash of a namespace + name), v4 (random — the most common), v5 (SHA-1 hash of a namespace + name). RFC 9562 added v6 (time-ordered, like v1 but without the MAC leak) and v7 (Unix timestamp + random — designed specifically for database primary keys because it sorts chronologically). This tool generates v4 UUIDs using crypto.randomUUID(), which uses cryptographically-strong randomness from the browser's underlying OS — the same source TLS keys come from. Output is byte-identical to Python's uuid.uuid4(), Node's crypto.randomUUID(), and Go's google/uuid.NewRandom().

Common use cases

  • Database primary keys — replace auto-incrementing integers when you need to merge databases or generate IDs client-side.

  • Session identifiers in cookies — long enough that brute-forcing a valid session ID is computationally infeasible.

  • Idempotency keys for API requests — repeat the request safely; the server deduplicates by UUID.

  • File upload identifiers — name uploaded files by UUID to prevent path collisions and avoid exposing original filenames.

  • Distributed tracing IDs — each request gets a UUID, propagated through services for log correlation.

  • Test fixture identifiers — predictable randomness for test data without coordinating IDs across test cases.

Frequently asked questions

What does v4 mean?
Version 4 — generated from 122 bits of randomness plus 6 fixed version/variant bits. Other versions: v1 is timestamp+MAC-based (don't use; leaks machine identity and time), v3/v5 are deterministic hashes of a namespace+name (useful for stable derived IDs), v7 is timestamp-prefixed random (excellent for databases because it sorts chronologically). For most needs, v4 is the right default.
How unique are UUIDs really?
v4 UUIDs have 122 effective bits of randomness — 5.3×10^36 possible values. You'd need to generate 2.71 quintillion UUIDs before reaching a 50% collision probability. For context, if you generated 1 billion UUIDs per second, you'd need 85 years to reach that threshold. Practical collisions don't happen with good RNG.
Should I use v4 or v7 for database primary keys?
v7 is better for databases. v4 UUIDs are random, which means new rows scatter randomly across B-tree indexes — causing index bloat and slow inserts at scale. v7 prefixes the timestamp, so new UUIDs always sort after old ones, keeping insertion patterns sequential. PostgreSQL, MySQL, and SQL Server all benefit from v7. If your library doesn't yet support v7, ULIDs are a popular alternative with the same property.
Is crypto.randomUUID() safe to use?
Yes. It's specified in WHATWG and implemented in every modern browser using the operating system's cryptographic RNG (the same source TLS keys come from). Output is unpredictable and uniformly distributed across the v4 UUID space.
What's the difference between UUID and GUID?
Functionally identical — GUID is Microsoft's term for the same concept. The byte format differs in some Microsoft APIs (.NET's Guid.ToByteArray() uses mixed-endian for the first three fields), so when interop matters, watch the byte order. The canonical string format (8-4-4-4-12) is identical.
Can I shorten a UUID for URLs?
Yes — encode the 128 bits in Base62 or Base64 instead of the canonical hex format. Base62 gives you 22 characters; Base64 gives 22 with padding or 22 url-safe. Some libraries also use 'short UUID' formats. The underlying bits are unchanged; only the display encoding differs.
Why does my UUID start with the same characters as another?
Coincidence — v4 UUIDs are random. With 36 hex characters total and only 22 random hex characters (4 are reserved for version/variant, 4 are dashes), some prefix collisions are inevitable when you generate many. The full UUID is unique even when prefixes match.

Related tools