UUID Generator

|

10 UUIDs · v4
  • 1a61a39ee-a052-48ac-9573-b6ed69affdb1
  • 2d50ed584-6525-4095-8de6-5a604a4d97c8
  • 365ae496e-a607-4fae-89a0-8cc8d1b4c6ac
  • 4a5936cfb-2482-41be-9c91-0dab6195f970
  • 545e6b571-8667-4c64-afcb-2b61415f881f
  • 67e68e698-1646-4b97-ba7c-968a63da936b
  • 778d69e5f-6dd8-4a2b-9396-2e3a72709cf7
  • 8fc40d18f-c129-4311-ba44-d433e084f49e
  • 9c739f163-ac18-4340-bc8a-da704870f3d8
  • 10e1277f81-e596-4959-be14-954010498704

Generate one or more UUID v4 identifiers instantly in your browser. Each UUID is a 128-bit random value formatted as xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, generated using the Web Crypto API.

What a UUID is

A UUID (Universally Unique Identifier) is a 128-bit label defined in RFC 4122. Its defining property is that it can be generated independently on any device, at any time, without coordination, and remain practically unique across all systems that use it.

UUIDs come in several versions. v1 encodes the current time and the generating machine's MAC address. v3 and v5 are deterministic — they hash a namespace and a name to produce a reproducible UUID. v4 is fully random. v7 (RFC 9562) embeds a millisecond timestamp for sort order. v4 is the most widely used for general-purpose identifiers.

The standard text representation is 32 hex digits in five hyphen-separated groups: 8-4-4-4-12. The total length is always 36 characters including hyphens.

Example UUID v4f47ac10b-58cc-4372-a567-0e02b2c3d479
Example UUID v49b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
Example UUID v41b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed

UUID v4 and randomness

UUID v4 uses 122 bits of random data. The remaining 6 bits encode the version (4) and the RFC 4122 variant, and are fixed. This tool generates UUIDs using crypto.randomUUID(), which is backed by the operating system's cryptographically secure random number generator — the same source used for TLS key generation.

The probability of two v4 UUIDs colliding is approximately 1 in 5.3 × 10³⁶ per pair. To put that concretely: generating 1 billion UUIDs per second for 100 years, the probability of any collision occurring remains below 0.000000006%. For practical purposes they are unique — but they are not mathematically guaranteed unique, and no implementation can make that guarantee.

If your application truly cannot tolerate even an astronomically unlikely collision (for example, cryptographic key material), UUID v4 is not the right primitive. For record identifiers, session tokens, file names, and correlation IDs, it is the appropriate choice.

Format templatexxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx (y ∈ {8, 9, a, b})
Version digit fixed9b1deb4d-3b7d-[4]bad-9bdd-... ← always 4
Variant digit fixed9b1deb4d-3b7d-4bad-[9]bdd-... ← always 8, 9, a, or b

UUID structure explained

A UUID v4 is 32 hexadecimal digits (128 bits) in five groups separated by hyphens: 8-4-4-4-12. The segment boundaries are historical convention from earlier versions; in v4 they carry no structural meaning.

Two positions are not random. The 13th character (first digit of the third group) is always 4 — the version. The 17th character (first digit of the fourth group) is always 8, 9, a, or b — the variant. These two markers allow validators and parsers to confirm a string is a well-formed UUID v4 without any other context.

UUIDs are case-insensitive. f47ac10b-... and F47AC10B-... represent the same value. Most databases and languages normalize to lowercase, but parsers accept both.

Annotatedf47ac10b-58cc-4372-a567-0e02b2c3d479 ^^^^ version=4 at position 13, variant=a at position 17
No hyphens (compact)f47ac10b58cc4372a5670e02b2c3d479 (same value, common in some DBs)
URN formurn:uuid:f47ac10b-58cc-4372-a567-0e02b2c3d479

UUIDs in databases, APIs, and distributed systems

Databases: UUIDs work as primary keys in PostgreSQL (uuid type), MySQL (CHAR(36) or BINARY(16)), and SQLite (TEXT). The main advantage is that IDs can be assigned in application code before the row is written, removing a database round-trip and enabling offline-first or multi-source insert patterns.

APIs: UUIDs in REST endpoints (/orders/f47ac10b-58cc-4372-a567-0e02b2c3d479) avoid exposing sequential counters that reveal record volume. They also prevent enumeration attacks where an attacker increments an integer ID to access records they should not see.

Distributed systems: when multiple services, regions, or clients create records independently and merge them later, sequential IDs conflict. UUIDs eliminate the coordination step — each service generates its own IDs with negligible collision risk.

Test fixtures: UUIDs are useful for seeding test databases with predictable-looking but non-sequential IDs, or for generating unique filenames for uploaded assets in test runs without cleanup dependencies.

REST resource URLGET /api/users/9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
SQL insertINSERT INTO orders (id, user_id, total) VALUES ('f47ac10b-58cc-4372-a567-0e02b2c3d479', '9b1deb4d-...', 4900);
Test fixtureconst USER_ID = "1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed"; // stable across test runs
Correlation ID headerX-Request-ID: f47ac10b-58cc-4372-a567-0e02b2c3d479

UUID v4 vs sequential IDs: tradeoffs

Sequential integer IDs (SERIAL, AUTO_INCREMENT, SEQUENCE) sort naturally, are compact (4–8 bytes vs 16), and index efficiently in B-trees because new rows always append to the right end of the index.

UUID v4 inserts into random positions in a B-tree index, causing page splits as the table grows. On tables with millions of rows and high insert rates, this produces measurable write amplification and index bloat. For read-heavy workloads or moderate insert rates, the effect is negligible.

UUID v4 exposes no information about insertion order, record count, or timing — a property that is useful for security but inconvenient when you need "show me the most recently created 10 records" without a separate timestamp column.

If you need both random IDs and sort order, UUID v7 or ULID are designed for this: they embed a timestamp prefix so generated values sort by creation time while remaining globally unique without coordination.

For most applications, UUID v4 as a primary key is a reasonable default. The B-tree performance concern only becomes material at high sustained insert rates on large tables.

Generating in bulk

Set the count and click Generate. All UUIDs are generated in one batch using Array.from({ length: n }, () => crypto.randomUUID()). Copy individual values with the row button, or use Copy All to get the full list.

Bulk generation is useful for seeding a test database with unique primary keys before writing the application code, pre-generating a set of asset filenames for a batch upload, or producing a list of one-time identifiers for a test fixture file.

Every UUID in a batch is independently random — they share no sequential or time-based relationship with each other.

UUID v1 vs v4 vs v5: Which Should You Use?

RFC 4122 defines five UUID versions, each with a different generation strategy. Picking the right one depends on whether you need randomness, time ordering, or deterministic reproducibility.

UUID v1 is generated from the current timestamp plus the host machine's MAC address. It guarantees uniqueness across machines without coordination, but it leaks the generating host's hardware identifier and the moment of generation — both privacy concerns for many applications.

UUID v3 and v5 are deterministic: they hash a namespace UUID together with a name string (v3 uses MD5, v5 uses SHA-1) to produce the same UUID every time the same inputs are given. Use v5 when you want stable identifiers derived from existing data — for example, deriving a content UUID from a URL.

UUID v4 is fully random (122 bits of entropy). It is the default choice when you need an opaque, unguessable identifier with no information leakage. Most modern applications, APIs, and database primary keys use v4.

UUID v7 (RFC 9562, 2024) embeds a millisecond Unix timestamp in the high bits with random data filling the rest. The result sorts lexicographically by creation time while remaining globally unique without coordination — the best of both worlds for database primary keys at high insert rates.

Recommendation: v4 for most opaque identifiers; v5 when you need a deterministic UUID from existing inputs; v7 when you need both global uniqueness and time-ordered insertion into a B-tree index. Avoid v1 in new systems unless you specifically need its time-MAC properties.
v1 — time + MAC5b3eafd6-cd45-11ee-8c60-325096b39f47 ← MAC of generator visible
v3 — MD5(namespace, name)5df41881-3aed-3515-88a7-2f4a814cf09e ← deterministic from input
v4 — randomf47ac10b-58cc-4372-a567-0e02b2c3d479 ← 122 random bits
v5 — SHA-1(namespace, name)2ed6657d-e927-568b-95e1-2665a8aea6a2 ← deterministic, preferred over v3
v7 — time + random (sortable)018e1f7c-3f2a-7a4d-9b3e-7c1e2a3b4c5d ← lexicographic sort = creation order

How to Generate a Random UUID in JavaScript, Python, and Go

Every modern runtime ships a built-in UUID v4 generator backed by the operating system's cryptographic RNG. The snippets below produce a fresh random UUID in each environment so you can drop them straight into application code without pulling in a dependency for the simple case.

JavaScript: crypto.randomUUID() is available in all modern browsers and in Node.js 14.17+. It returns a v4 UUID as a lowercase string and uses the same secure random source as TLS key generation. No npm package required.

Python: the uuid module is in the standard library — no pip install needed. uuid.uuid4() returns a UUID object; wrap it with str() to get the canonical hyphenated form. For a deterministic v5 UUID, use uuid.uuid5(namespace, name).

Go: the standard library does not include UUID generation, but github.com/google/uuid is the de-facto package. uuid.New() returns a v4 UUID, and .String() formats it as the canonical 36-character form.

JavaScript (browser & Node.js 14.17+)crypto.randomUUID() // → "f47ac10b-58cc-4372-a567-0e02b2c3d479"
JavaScript — bulkArray.from({ length: 5 }, () => crypto.randomUUID())
Python — random v4import uuid str(uuid.uuid4()) # → "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d"
Python — deterministic v5import uuid str(uuid.uuid5(uuid.NAMESPACE_URL, "https://example.com/users/42"))
Go — random v4import "github.com/google/uuid" uuid.New().String() // → "1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed"
Bash (uuidgen)uuidgen # → 550e8400-e29b-41d4-a716-446655440000
PostgreSQLSELECT gen_random_uuid(); -- → 550e8400-e29b-41d4-a716-446655440000

UUID Format and Structure Explained

A UUID is 128 bits (16 bytes), rendered as 32 hexadecimal characters in five hyphen-separated groups: 8-4-4-4-12. The total length is always 36 characters, including the four hyphens. Lowercase is conventional but parsers accept either case.

The five groups originate from earlier UUID versions where each segment encoded a specific field — time-low, time-mid, time-high-and-version, clock-sequence, and node. In v4 the segment boundaries no longer carry semantic meaning, but the version and variant nibbles in fixed positions still identify which generation strategy produced the value.

Two characters are not random in v4: the 13th character (M in xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx) is the version digit and is always 4 for v4, 7 for v7, and so on. The 17th character (N) is the variant nibble and is always one of 8, 9, a, or b for RFC 4122 UUIDs.

Two special UUIDs are reserved as sentinels. The Nil UUID (all zeros: 00000000-0000-0000-0000-000000000000) represents "no value" or an uninitialised reference, similar to NULL in SQL. The Max UUID (all ones: ffffffff-ffff-ffff-ffff-ffffffffffff), formalised in RFC 9562, is the lexicographic upper bound and is sometimes used as a sentinel for "end of range" in sorted indexes.

Canonical formf47ac10b-58cc-4372-a567-0e02b2c3d479 (36 chars, 8-4-4-4-12)
Group 1 (8 hex)f47ac10b ← time-low (legacy field name)
Group 2 (4 hex)58cc ← time-mid
Group 3 (4 hex)4372 ← first digit = version (4 here)
Group 4 (4 hex)a567 ← first digit = variant (8/9/a/b)
Group 5 (12 hex)0e02b2c3d479 ← node / random tail
Nil UUID00000000-0000-0000-0000-000000000000 (sentinel for "none")
Max UUIDffffffff-ffff-ffff-ffff-ffffffffffff (sentinel for "end of range")
Compact (no hyphens)f47ac10b58cc4372a5670e02b2c3d479 (32 chars, accepted by some parsers)

Common UUID Use Cases

Database primary keys: UUIDs let application code assign IDs before writing rows, removing a database round-trip and enabling offline-first writes, multi-region inserts, and client-generated IDs that survive network failures. PostgreSQL has a native uuid type; MySQL stores them as BINARY(16) for efficiency or CHAR(36) for readability.

Distributed system identifiers: when independent services or shards must produce unique IDs without coordination, UUIDs eliminate the need for a central sequence generator. Two services on different continents can mint IDs simultaneously with no risk of collision.

File and object names: cloud storage paths like s3://bucket/uploads/9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d.jpg use UUIDs to avoid filename collisions across simultaneous uploads, prevent guessing of neighbouring files, and decouple storage paths from user-facing names.

Session tokens and correlation IDs: a UUID v4 in a Set-Cookie header or an X-Request-ID HTTP header is unguessable, easy to log, and useful for tracing a single request across microservices. For session security tokens with long lifetimes, prefer a longer random token (32+ bytes); UUID v4's 122 bits of entropy are sufficient for most short-lived correlation purposes.

Idempotency keys: APIs that accept POST requests (payments, order creation) often require a client-supplied idempotency key — a UUID is the standard choice. The server stores the key with the response and returns the cached response if the same key is replayed, making retries safe across network failures.

Primary keyINSERT INTO users (id, email) VALUES ('f47ac10b-58cc-4372-a567-0e02b2c3d479', 'a@b.com');
API resource URLGET /api/orders/9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
Object storage paths3://uploads/2024/03/15/1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed.pdf
Session cookieSet-Cookie: session=550e8400-e29b-41d4-a716-446655440000; HttpOnly; Secure
Correlation headerX-Request-ID: f47ac10b-58cc-4372-a567-0e02b2c3d479
Idempotency keyIdempotency-Key: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d

Frequently Asked Questions

What is the format of a UUID v4?
Thirty-two hex digits split into five groups by hyphens: 8-4-4-4-12. Total length is 36 characters. Example: 550e8400-e29b-41d4-a716-446655440000. The 4 in position 13 and the 8/9/a/b in position 17 are the only non-random characters — they encode version and variant.
Can two different requests get the same UUID?
In practice, no. The probability per pair is approximately 1 in 5.3 × 10³⁶. Generating 1 billion UUIDs per second for 86 years gives a collision probability below 50% — and real workloads are far smaller than that. UUID v4 collision is not a realistic failure mode for application identifiers.
How do I validate whether a string is a valid UUID?
Use a regex against the standard format: /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i. The 4 before the third group and the [89ab] before the fourth group check for v4 specifically. Most languages also have a UUID library with a built-in parse/validate function.
Are these safe to use as database primary keys?
Yes for most use cases, with one caveat: random UUIDs insert into random positions in a B-tree index, which causes page splits at high insert rates on large tables. For high-insert workloads, UUID v7 or ULID (both time-sortable) reduce that fragmentation. For typical application workloads, v4 performs acceptably.
Can I generate UUIDs without this tool?
Yes. Node.js 14.17+: crypto.randomUUID(). Python: import uuid; str(uuid.uuid4()). Go: github.com/google/uuid package. PostgreSQL: gen_random_uuid() (or uuid_generate_v4() with the uuid-ossp extension). Browser console: crypto.randomUUID().
What is the difference between UUID v4 and UUID v7?
UUID v4 is purely random — no time component, no sort order. UUID v7 (RFC 9562) embeds a millisecond Unix timestamp in the most significant bits, so v7 values sort lexicographically by creation time. For database primary keys with frequent inserts, v7 reduces B-tree page splits. v7 requires a library in most environments; it is not yet natively available in Node.js or Python without a package.
Are generated UUIDs logged or stored?
No. Generation happens entirely in your browser using the Web Crypto API. The values are never sent to any server.
What is the difference between UUID v4 and v7?
UUID v4 is 122 bits of pure randomness — values appear in arbitrary order and reveal nothing about when they were created. UUID v7 (RFC 9562) reserves the first 48 bits for a millisecond Unix timestamp and fills the rest with random data, so v7 values sort lexicographically by creation time. The practical effect: when v7 UUIDs are used as a primary key, new rows append to the right end of a B-tree index just like an auto-incrementing integer, avoiding the page-split write amplification that v4 causes at high insert rates. Choose v4 for opaque identifiers where order leakage is undesirable; choose v7 for primary keys on write-heavy tables.
Are UUIDs truly unique? What are the collision odds?
UUID v4 is not mathematically guaranteed unique — it is statistically unique. The probability of two random v4 UUIDs colliding is approximately 1 in 2¹²² ≈ 1 in 5.3 × 10³⁶ per pair. To reach a 50% collision probability you would need to generate roughly 2.71 × 10¹⁸ UUIDs (2.71 quintillion). Generating 1 billion UUIDs per second, that takes about 86 years. For application identifiers, session tokens, and database primary keys, collisions are not a realistic failure mode. For cryptographic key material, use a dedicated key-generation primitive instead — UUIDs are not designed for that purpose.
How do I generate a UUID in JavaScript without a library?
Use the built-in Web Crypto API: crypto.randomUUID() returns a v4 UUID string. It works in all modern browsers (Chrome 92+, Firefox 95+, Safari 15.4+) and in Node.js 14.17+, with no npm package required. Example: const id = crypto.randomUUID(); // → "f47ac10b-58cc-4372-a567-0e02b2c3d479". For older runtimes that do not support randomUUID, fall back to crypto.getRandomValues(new Uint8Array(16)) and set the version (byte 6 = 0x40 | (byte & 0x0f)) and variant (byte 8 = 0x80 | (byte & 0x3f)) bits manually before formatting as hex.
Can I use UUID as a database primary key?
Yes. PostgreSQL has a native uuid type (16 bytes) — store as uuid, not text. MySQL is best stored as BINARY(16); CHAR(36) works but uses more than twice the space and slows index lookups. SQLite has no native type, so use TEXT. The main caveat is index fragmentation: random v4 values insert into random positions in a B-tree, causing page splits and write amplification on tables with sustained high insert rates. If that is a concern, switch to UUID v7 or ULID, which embed a timestamp prefix so inserts append to the right end of the index. For typical CRUD workloads, v4 as a primary key is a reasonable default and the fragmentation cost is negligible.

Related Tools