DevFormatter

UUID Generator

Validate a UUID

Accepts standard, uppercase, no-hyphens, braces {} and URN formats.

Generated UUIDs

Click Generate to create UUIDs.

A UUID (Universally Unique Identifier) is a 128-bit identifier standardised in RFC 9562 used to identify resources without central coordination. This free online UUID generator creates UUID v4 (random), UUID v7 (time-ordered), and nil UUIDs directly in your browser using the Web Crypto API — no data leaves your machine.

UUID Generator & Validator

How it works

Last updated: November 2026

A UUID (Universally Unique Identifier) is a 128-bit identifier standardised in RFC 9562 used to identify resources without central coordination. This tool generates UUID v4 (random), UUID v7 (time-ordered), and nil UUIDs directly in your browser using the Web Crypto API — no data leaves your machine.

  • UUID v4 — 122 random bits via crypto.randomUUID(). Use for session tokens, entity IDs, and anything requiring unpredictability.
  • UUID v7 — 48-bit Unix ms timestamp + 74 random bits (RFC 9562). UUIDs are time-ordered, making them ideal for database primary keys where sequential writes matter.
  • Nil UUID — All zeros. Used as a sentinel or default value.

Select a version, format, and count, then click Generate. Each UUID in the output has a copy button. Use Copy All to copy every UUID as a newline-separated list.

UUID Structure

A UUID has 32 hexadecimal digits in five hyphen-separated groups: 8-4-4-4-12 characters. Two positions carry fixed meaning:

Position Meaning Example (v4)
Char 14 (M) Version digit (1–8) 550e8400-e29b-41d4-…
Char 19 (N) Variant bits — must be 8, 9, a, or b …-41d4-a716-…
Bytes 0–5 (v7 only) 48-bit Unix ms timestamp 018f5e9d-6e1b-7000-…
Format Example
Standard 550e8400-e29b-41d4-a716-446655440000
Uppercase 550E8400-E29B-41D4-A716-446655440000
No hyphens 550e8400e29b41d4a716446655440000
Braces {550e8400-e29b-41d4-a716-446655440000}
URN urn:uuid:550e8400-e29b-41d4-a716-446655440000

Tips & Tricks

Use UUID v7 for database PKs

UUID v7's timestamp prefix keeps inserts sequential in B-tree indexes, avoiding page splits that slow down high-write tables. PostgreSQL 17+ has built-in gen_random_uuid() — for v7, use the pg_uuidv7 extension.

Store as binary(16) not varchar(36)

Storing a UUID as a 36-char string uses 36 bytes; as binary(16) it uses 16 bytes — 55% smaller. For a table with 100M rows, that's roughly 2 GB saved on the index alone. MySQL, PostgreSQL and SQLite all support binary UUID storage.

Version 4 is not fully random

UUID v4 has 122 random bits, not 128. Six bits are fixed: 4 version bits and 2 variant bits. This means there are 2¹²² ≈ 5.3 × 10³⁶ possible v4 UUIDs, not 2¹²⁸. The difference is irrelevant for collision probability but matters if you're doing bitwise entropy calculations.

UUID v7 timestamps are extractable

The first 12 hex chars of a UUID v7 encode the creation time in milliseconds. You can extract it: parseInt(uuid.replace(/-/g,'').slice(0,12), 16) gives Unix ms. This is a feature for auditing, but a privacy concern if UUIDs are user-facing.

Don't use UUID v1 for new systems

UUID v1 encodes the MAC address of the generating machine, which is a privacy leak. It has been superseded by v7 for time-ordered use cases. RFC 9562 (2024) formally deprecated UUID v1 in favour of v6 and v7.

Validate the variant byte, not just the format

A string matching the UUID regex pattern could still be invalid if the variant nibble (position 19) isn't 8, 9, a, or b. These two bits identify an RFC 9562 UUID. The nil UUID (all zeros) is an exception — its variant byte is 0 by definition.

Code Examples

Node.js

// Node.js 15+ (built-in)
const uuid = crypto.randomUUID(); // UUID v4
console.log(uuid); // e.g. '110e8400-e29b-41d4-a716-446655440000'

// UUID v7 (time-ordered) — no built-in, use the uuid package
// npm install uuid
const { v7: uuidv7 } = require('uuid');
console.log(uuidv7()); // e.g. '018f5e9d-6e1b-7000-8000-b4b2a3c4d5e6'

// Bulk generation
const ids = Array.from({ length: 10 }, () => crypto.randomUUID());

Python

import uuid

# UUID v4 (random)
print(uuid.uuid4())          # 550e8400-e29b-41d4-a716-446655440000

# UUID v5 (name-based, deterministic)
print(uuid.uuid5(uuid.NAMESPACE_DNS, 'devformatter.org'))

# No-hyphens format
raw = uuid.uuid4().hex        # 32 hex chars, no hyphens

# UUID v7 (time-ordered)
# pip install uuid7
from uuid_extensions import uuid7
print(uuid7())

CLI

# macOS / Linux — generate UUID v4
uuidgen              # uppercase on macOS: A5B2C3D4-...
uuidgen | tr 'A-Z' 'a-z'   # lowercase

# Python one-liner
python3 -c "import uuid; print(uuid.uuid4())"

# Node.js one-liner
node -e "console.log(crypto.randomUUID())"

# Bulk: 10 UUIDs
python3 -c "import uuid; [print(uuid.uuid4()) for _ in range(10)]"

Frequently Asked Questions

What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit label standardised by RFC 9562 (which obsoleted RFC 4122 in 2024) used to identify information in computer systems without central coordination. Written as 32 hexadecimal digits separated by hyphens in the form xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx, the character M encodes the UUID version (1–8) and the character N encodes the variant (must be 8, 9, a, or b for RFC 9562 UUIDs). A well-known example is 550e8400-e29b-41d4-a716-446655440000. UUIDs are used as database primary keys, session tokens, file names, API resource identifiers, and distributed system node IDs — any context where uniqueness is required across multiple machines without a central counter. The probability of generating a duplicate UUID v4 is roughly 1 in 5.3 × 10³⁶, making collisions practically impossible. RFC 9562 defines eight UUID versions: v1 (time + MAC), v3 (name-based MD5), v4 (random), v5 (name-based SHA-1), v6 (reordered time), v7 (Unix timestamp), and v8 (custom).
What is the difference between UUID v4 and UUID v7?
UUID v4 is entirely random — 122 bits of cryptographic randomness generated by crypto.randomUUID() (browsers, Node.js 15+) or uuid.uuid4() (Python stdlib). Its unpredictability makes it suitable for session tokens, API keys, and any security-sensitive identifier. UUID v7 (RFC 9562, standardised in 2024) encodes a 48-bit Unix millisecond timestamp in its most-significant bytes, so v7 UUIDs sort chronologically — a UUID generated later will always be lexicographically greater than one generated earlier. This matters for database performance: B-tree indexes on UUID v4 columns receive random page writes, causing index fragmentation and cache misses at scale; B-tree indexes on UUID v7 columns receive mostly sequential writes, similar to an auto-increment integer. PostgreSQL 17 does not yet have a built-in gen_uuid_v7() function, but the pg_uuidv7 extension (available on AWS RDS and Supabase) adds one. MySQL 8.0 and SQLite do not have native UUID v7 support — generate them in application code and insert as a string or binary(16).
What is a GUID and is it the same as a UUID?
GUID (Globally Unique Identifier) is Microsoft's name for UUID. The two terms refer to the same 128-bit identifier format — a GUID is a UUID, and vice versa. Windows APIs, COM, and .NET use the term GUID; most other platforms, including Linux, macOS, Java, Python, and Go, use the term UUID. In .NET, you create one with Guid.NewGuid(), which returns a GUID in the braces format {550e8400-e29b-41d4-a716-446655440000} by default. The Windows registry stores GUIDs as the identifier for COM objects, Windows services, and installed applications. SQL Server calls them uniqueidentifier columns, with NEWID() generating a random v4 GUID and NEWSEQUENTIALID() generating a sequential one for index-friendly inserts.
What is a nil UUID?
The nil UUID is the special value with all 128 bits set to zero: 00000000-0000-0000-0000-000000000000. It is defined in RFC 9562 and used as a sentinel or null value — for example as a default primary key value before an ID has been assigned, or in test fixtures where a consistent predictable UUID is needed. In database schemas, the nil UUID can be used as a foreign key placeholder indicating "not yet linked", making it safe to use in NOT NULL columns without introducing SQL NULL semantics. In Go, the github.com/google/uuid package exposes it as uuid.Nil; in Python it is uuid.UUID(int=0). RFC 9562 also defines a "max UUID" with all 128 bits set to one (ffffffff-ffff-ffff-ffff-ffffffffffff), which can serve as a sentinel for the maximum ID value in range queries.
Is UUID v4 safe to use as a database primary key?
UUID v4 works as a primary key but has a significant drawback: because v4 UUIDs are random, each insert writes to a random position in the B-tree index, causing page splits and poor cache locality as the table grows. At table sizes above a few million rows this leads to measurable write amplification and slower INSERT performance compared to sequential IDs. For high-insert tables, UUID v7 or ULID are better choices — their timestamp prefix keeps inserts monotonically increasing, similar to an auto-increment integer. If you must use UUID v4 in PostgreSQL, store it in a native uuid column (16 bytes) rather than varchar(36) (36 bytes plus padding), which saves about 55% index space and allows PostgreSQL to use the uuid operator class. In MySQL, consider storing as binary(16) using UNHEX(REPLACE(uuid, '-', '')) and reading back with INSERT(INSERT(INSERT(INSERT(HEX(id),9,0,'-'),14,0,'-'),19,0,'-'),24,0,'-').
How do I generate a UUID in JavaScript?
In Node.js 15+ and all modern browsers, use the built-in: crypto.randomUUID() — no library needed. This returns a UUID v4 string directly, e.g. '110e8400-e29b-41d4-a716-446655440000'. In older Node.js (12 or 14), use the uuid package: const { v4: uuidv4 } = require('uuid'); uuidv4();. For UUID v7 in Node.js, the same uuid package provides const { v7: uuidv7 } = require('uuid'); uuidv7(); — available since uuid@10. For bulk generation, Array.from({ length: 100 }, () => crypto.randomUUID()) generates 100 UUIDs without any loop boilerplate. crypto.randomUUID() is available in Deno, Bun, Cloudflare Workers, and all major browser runtimes — it uses the platform's cryptographically secure random number generator (CSPRNG) and is safe for security-sensitive use cases.
How do I generate a UUID in Python?
Python's standard library has the uuid module — no pip install needed: import uuid; str(uuid.uuid4()) generates a UUID v4 string such as '550e8400-e29b-41d4-a716-446655440000'. Use uuid.uuid4().hex for the no-hyphens format (32 hex chars) or str(uuid.uuid4()).upper() for uppercase. For UUID v7 (time-ordered), install the third-party uuid7 package (pip install uuid7) and use from uuid_extensions import uuid7; str(uuid7()). The Python stdlib does not yet include a native UUID v7 implementation — a CPython enhancement proposal (PEP) to add it is under discussion as of 2024. For deterministic UUIDs based on a name (useful in tests), use uuid.uuid5(uuid.NAMESPACE_DNS, 'example.com'), which always returns the same UUID for the same input, making test fixtures reproducible.
What UUID format should I use?
Use standard (lowercase with hyphens) in most cases — it is the canonical RFC 9562 format and is accepted by every UUID parser and database driver. For example: 550e8400-e29b-41d4-a716-446655440000. Use no-hyphens (32 hex characters) when storing in a fixed-width database column such as char(32) or binary(16) — this avoids storing the four hyphen characters and saves 4 bytes per row. Use the URN format (urn:uuid:550e8400-...) when embedding a UUID in an XML document, RDF triple store, or JSON-LD context where a full URI is required as the identifier. The braces format ({550e8400-...}) is the Windows COM and .NET convention, produced by Guid.NewGuid().ToString("B") — it is rarely needed outside of .NET interop. Uppercase format is sometimes required by older Microsoft systems and is functionally identical to standard, since UUID values are case-insensitive per the RFC.
How do I validate a UUID?
A valid RFC 9562 UUID matches the regex pattern /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i. The character at position 14 (the M character, 0-indexed) is the version digit and must be 1–8 for any currently defined UUID version. The character at position 19 (the N character) must be 8, 9, a, or b — these are the two most-significant variant bits (binary 10xx) that identify an RFC 9562 UUID. The nil UUID (00000000-0000-0000-0000-000000000000) is an exception — its variant byte is 0 by definition. The DevFormatter UUID Generator's validator panel accepts standard, uppercase, no-hyphens, braces, and URN formats and checks both the structure regex and the variant byte. In JavaScript you can validate programmatically using the uuid package's validate(str) function, which returns a boolean.
Can two UUIDs ever be the same?
In theory yes, but the probability is negligible and treated as impossible in practice. For UUID v4, there are 2¹²² (approximately 5.3 × 10³⁶) possible values. To reach a 50% probability of at least one collision — the birthday problem — you would need to generate approximately 2.7 × 10¹⁸ UUIDs. At a generation rate of one billion UUIDs per second, reaching that threshold would take roughly 85 years. By comparison, the total number of UUIDs generated across all human systems since UUID was invented is estimated to be far below 10¹⁸. The randomness of UUID v4 comes from a cryptographically secure RNG (CSPRNG): crypto.randomUUID() in browsers and Node.js uses the OS entropy source (usually hardware-assisted). UUID v7 collisions are even less likely because the timestamp prefix differentiates UUIDs generated in different milliseconds; within the same millisecond, the remaining 74 random bits still provide extraordinary uniqueness. No production system should include collision-detection logic for UUID v4 or v7.
Is my data sent to a server?
No. All UUID generation runs entirely in your browser using the Web Crypto API — specifically crypto.randomUUID() for UUID v4 and crypto.getRandomValues() for the random bits in UUID v7. No data is sent to any server, no UUIDs are logged, and no account is required. This matters for security: if you use UUIDs as tokens, session IDs, or secret keys, generating them client-side means they never transit a network before reaching your code. The Web Crypto API's CSPRNG is seeded by the operating system's entropy source (hardware RNG on modern CPUs), making the generated values cryptographically unpredictable. DevFormatter is an entirely static site — there is no backend server that could intercept or store generated values. You can verify this by checking the browser's Network tab: no outbound requests are made when you click Generate.

Related Tools

Other free developer tools available on DevFormatter.