Free UUID Generator — Generate Random v4 UUIDs Instantly

Generate cryptographically secure UUID v4 identifiers with one click

UUID Generator

Generate cryptographically secure version 4 UUIDs

Ready to generate.
All UUIDs are generated locally in your browser.

UUID Inspector

Generate a UUID to inspect its structure.

Status Waiting for generated UUID
🎲

Click Generate or a preset to create UUIDs

UUID v4 Format Breakdown

A UUID v4 is a 128-bit identifier displayed as 32 hexadecimal characters in 5 groups:

xxxxxxxx - xxxx - 4xxx - yxxx - xxxxxxxxxxxx
Time Low (8 chars) Random in v4
Time Mid (4 chars) Random in v4
Version (4 chars) Starts with "4" for v4
Variant (4 chars) First char: 8, 9, a, or b
Node (12 chars) Random in v4

About UUIDs

🔐 Cryptographically Secure

Uses crypto.randomUUID() or crypto.getRandomValues() for unpredictable randomness. Safe for security-sensitive applications.

🌍 Universally Unique

With 122 random bits, the probability of collision is astronomically low—even generating billions of UUIDs.

💻 Common Use Cases

  • Database primary keys
  • API request identifiers
  • Session tokens
  • File naming
  • Distributed systems

📋 Format Options

With hyphens: Standard RFC 4122 format (36 chars)
Without hyphens: Compact format for URLs/filenames (32 chars)
Uppercase: Some systems prefer uppercase hex

UUID Versions Compared

The UUID specification defines several versions. Each generates identifiers differently:

VersionBased OnRandom BitsSortableBest For
v1 Timestamp + MAC address ~14 By time (partially) Legacy systems. Privacy concern: leaks hardware and time info.
v4 Random 122 No General-purpose. Most widely used. No information leakage.
v5 SHA-1 hash of namespace + name 0 (deterministic) No Consistent IDs from known inputs (e.g., URLs, DNS names).
v7 Timestamp + random ~62 Yes (time-ordered) Database primary keys. Introduced in RFC 9562 (2024).

This generator creates UUID v4 — the version recommended for most applications where you need a unique, random identifier.

How to Generate UUIDs in Code

Most languages have built-in or standard-library support for UUID generation:

JavaScript (Browser & Node.js 19+)
// Preferred — built-in, cryptographically secure
var id = crypto.randomUUID();
// → "3b241101-e2bb-4d7a-8613-e4ce89c1fc23"

// Fallback for older environments
function uuidv4() {
  var bytes = new Uint8Array(16);
  crypto.getRandomValues(bytes);
  bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
  bytes[8] = (bytes[8] & 0x3f) | 0x80; // variant 1
  var hex = [...bytes].map(b => b.toString(16).padStart(2, '0')).join('');
  return `${hex.slice(0,8)}-${hex.slice(8,12)}-${hex.slice(12,16)}-${hex.slice(16,20)}-${hex.slice(20)}`;
}
Python
import uuid

# Random UUID v4
my_id = uuid.uuid4()
print(my_id)  # → 550e8400-e29b-41d4-a716-446655440000

# Deterministic UUID v5 (namespace + name)
dns_uuid = uuid.uuid5(uuid.NAMESPACE_DNS, "example.com")
SQL (PostgreSQL)
-- Native UUID type with auto-generation
CREATE TABLE users (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  name TEXT NOT NULL
);

-- Insert without specifying ID
INSERT INTO users (name) VALUES ('Alice');
-- id → auto-generated UUID v4
Command Line (Linux/macOS)
# Linux
uuidgen

# macOS
uuidgen | tr '[:upper:]' '[:lower:]'

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

For production use, always prefer the language's built-in UUID library over manual implementations. Built-in functions handle version bits, variant bits, and cryptographic randomness correctly.

Common Mistakes

  • Using Math.random() for UUID generation: Math.random() is not cryptographically secure and can produce predictable outputs. Always use crypto.randomUUID() or crypto.getRandomValues().
  • Assuming UUIDs are sortable: UUID v4 is random — there is no time ordering. If you need sortable IDs, use UUID v7 or a separate timestamp column.
  • Storing UUIDs as plain text in databases: A UUID stored as CHAR(36) uses 36 bytes. Most databases support a native UUID or BINARY(16) type that uses 16 bytes — less than half the storage and faster to index.
  • Using UUID v1 and leaking private information: UUID v1 embeds the MAC address and creation timestamp. This can reveal when and on which machine the ID was generated. Use v4 or v7 when privacy matters.
  • Treating UUIDs as case-sensitive: UUIDs are case-insensitive. 550E8400... and 550e8400... represent the same identifier. Normalize to lowercase for storage and comparison.
  • Relying on UUIDs for access control: While UUID v4 is hard to guess, knowing a UUID should not be the only requirement to access a resource. Always combine UUIDs with proper authentication and authorization.

Frequently Asked Questions

What is a UUID?

A UUID (Universally Unique Identifier) is a 128-bit identifier represented as 32 hexadecimal characters in five groups separated by hyphens. UUIDs can be generated independently on any system without coordination and are practically guaranteed to be unique. The standard format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

What is the difference between a UUID and a GUID?

UUID and GUID refer to the same thing. UUID (Universally Unique Identifier) is the standard term defined in RFC 4122. GUID (Globally Unique Identifier) is Microsoft's name for the same concept, used in .NET, Windows APIs, and SQL Server. The format and generation methods are identical.

What is UUID v4?

UUID v4 is the most commonly used UUID version. It is generated from 122 bits of cryptographically secure random data. The only fixed bits are the version indicator (the digit 4 in the third group) and the variant bits (the first hex digit of the fourth group is 8, 9, a, or b). UUID v4 does not contain any timestamp or hardware information.

What is the probability of a UUID collision?

With 122 random bits, the probability is astronomically low. You would need to generate approximately 2.71 quintillion (2.71 × 1018) UUID v4 values to have a 50% chance of a single collision. In practical terms, generating 1 billion UUIDs per second for 85 years gives a 50% collision probability. For all real-world applications, UUID collisions effectively do not happen.

What is the difference between UUID v4 and UUID v7?

UUID v4 is entirely random, while UUID v7 (defined in RFC 9562, published 2024) embeds a Unix timestamp in the first 48 bits followed by random data. UUID v7 is time-sortable, which significantly improves B-tree index performance in databases. Use v4 when you want no information leakage; use v7 when sort order and storage locality matter.

Should I use UUIDs as database primary keys?

UUIDs work well as primary keys in distributed systems because they can be generated without a central authority. The main trade-off is performance: random UUID v4 values fragment B-tree indexes because inserts scatter across the index. For large tables, consider UUID v7 (time-ordered) or use UUIDs as a secondary identifier alongside an auto-increment primary key.

Are UUIDs secure enough for session tokens?

UUID v4 generated with a cryptographic random number generator provides 122 bits of entropy, which is sufficient for most session token use cases. However, dedicated session token formats — like JWTs or opaque tokens with server-side storage — offer additional features such as expiry, payload, and revocation. For simple session IDs, UUID v4 is adequate.

How do I generate a UUID in JavaScript?

In modern browsers and Node.js 19+, call crypto.randomUUID() — it returns a UUID v4 string directly. For older environments, use crypto.getRandomValues() to fill a 16-byte array, set the version and variant bits manually, and format the result as a hyphenated hex string.

How do I generate a UUID in Python?

Use the built-in uuid module: import uuid; my_id = uuid.uuid4(). This returns a UUID object; convert to string with str(my_id). Python also supports uuid1() (timestamp), uuid3() (MD5 namespace), and uuid5() (SHA-1 namespace).

Can I validate a UUID format?

Yes. A general UUID matches the regex [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}. For UUID v4 specifically, the third group starts with 4 and the fourth group starts with 8, 9, a, or b.

What characters are in a UUID?

A UUID contains hexadecimal characters (0-9 and a-f) and hyphens. The standard format is 8-4-4-4-12 characters, totaling 36 characters with hyphens or 32 characters without. UUIDs are case-insensitive; lowercase is conventional.

Does this UUID generator store my data?

No. UUIDs are generated entirely in your browser using the Web Crypto API (crypto.randomUUID or crypto.getRandomValues). Nothing is sent to any server. No cookies, no tracking, no storage.

Related Tools

Privacy & Limitations

  • Client-side only. No data is sent to any server. UUIDs are generated using the Web Crypto API in your browser. No cookies, no tracking.
  • UUID v4 only. This tool generates version 4 (random) UUIDs. It does not generate v1 (timestamp), v5 (namespace), or v7 (time-ordered) UUIDs.
  • Browser crypto required. This tool requires a browser that supports crypto.randomUUID() or crypto.getRandomValues(). If secure crypto APIs are not available, generation is disabled.
  • No uniqueness guarantee across sessions. While UUID v4 collision probability is astronomically low, this tool does not check generated UUIDs against any database. Your application should handle uniqueness constraints if needed.

Related Tools

View all tools

UUID Generator FAQ

What is a UUID?

A UUID (Universally Unique Identifier) is a 128-bit identifier represented as 32 hexadecimal characters in five groups separated by hyphens (e.g., 550e8400-e29b-41d4-a716-446655440000). UUIDs can be generated independently on any system without coordination and are practically guaranteed to be unique.

What is the difference between a UUID and a GUID?

UUID and GUID are the same thing. UUID (Universally Unique Identifier) is the standard term used in RFC 4122 and most programming languages. GUID (Globally Unique Identifier) is Microsoft's name for the same concept, used in .NET, Windows APIs, and SQL Server. The format and generation algorithms are identical.

What is UUID v4?

UUID v4 is the most commonly used UUID version. It is generated from 122 bits of cryptographically secure random data. The only fixed bits are the version indicator (the digit 4 in the third group) and the variant bits. UUID v4 does not contain any timestamp or hardware information, making it privacy-safe.

What is the probability of a UUID collision?

Extremely low. With 122 random bits, you would need to generate approximately 2.71 quintillion (2.71 × 10^18) UUIDs to have a 50% chance of a single collision. In practical terms, generating 1 billion UUIDs per second for 85 years yields a 50% collision probability. For all real-world applications, UUID collisions will not happen.

What is the difference between UUID v4 and UUID v7?

UUID v4 is entirely random, while UUID v7 (defined in RFC 9562, 2024) embeds a Unix timestamp in the first 48 bits followed by random data. UUID v7 is time-sortable, which improves database index performance for large tables. Use v4 when you need no information leakage; use v7 when sort order and index locality matter.

Are UUIDs secure enough for session tokens?

UUID v4 generated with a cryptographically secure random number generator (like crypto.randomUUID() in browsers or crypto.randomUUID() in Node.js) provides 122 bits of randomness, which is sufficient for most session token use cases. However, dedicated session token formats (like JWTs or opaque tokens with server-side storage) offer additional features like expiry and payload.

Should I use UUIDs as database primary keys?

UUIDs work well as primary keys in distributed systems because they can be generated independently without a central authority. The main trade-off is performance: random UUID v4 values fragment B-tree indexes. For large tables, consider UUID v7 (time-ordered) or use UUIDs as secondary identifiers alongside an auto-increment primary key.

How do I generate a UUID in JavaScript?

In modern browsers and Node.js 19+, use crypto.randomUUID() which returns a UUID v4 string. For older environments, use crypto.getRandomValues() to generate 16 random bytes, then set the version (4) and variant bits manually and format as a hex string with hyphens.

How do I generate a UUID in Python?

Use the built-in uuid module: import uuid; my_id = uuid.uuid4(). This returns a UUID object; use str(my_id) to get the string representation. Python also supports uuid1() (timestamp-based), uuid3() (MD5 namespace), and uuid5() (SHA-1 namespace).

What characters are in a UUID?

A UUID contains only hexadecimal characters (0-9 and a-f) and hyphens. The standard format is 8-4-4-4-12 characters separated by hyphens, totaling 36 characters (32 hex digits plus 4 hyphens). Without hyphens, a UUID is 32 characters.

Can I validate a UUID format?

Yes. A UUID v4 matches the regex pattern: [0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}. The third group always starts with 4 (the version), and the fourth group starts with 8, 9, a, or b (the variant). For any UUID version, use the general pattern: [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}.

Does this UUID generator store my data?

No. UUIDs are generated entirely in your browser using the Web Crypto API (crypto.randomUUID or crypto.getRandomValues). Nothing is sent to any server. No cookies, no tracking, no storage.

Request a New Tool
Improve This Tool