UUID Generator
Generate random UUIDs (v4), time-based UUIDs (v7), and ULIDs instantly. Bulk generate up to 100 at once. Free online UUID generator for developers — no signup required.
Click Generate to create UUIDs
What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit identifier standardized by RFC 4122 that is designed to be unique across all systems without requiring a central coordinating authority. UUIDs are fundamental to modern software architecture — they serve as database primary keys, API resource identifiers, distributed system correlation IDs, file names, session tokens, and message queue deduplication keys. The probability of generating a duplicate UUID v4 is so astronomically low (about 1 in 2.71×10¹⁸ after 103 trillion generations) that for all practical purposes, every UUID you generate is unique.
The standard UUID format is a 36-character string of hexadecimal digits displayed in five groups separated by hyphens: xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx, where M indicates the version and N indicates the variant. Different UUID versions serve different purposes — version 4 uses pure randomness, version 7 embeds a timestamp for sortability, and ULIDs offer a compact alternative with lexicographic ordering.
This generator creates UUIDs entirely in your browser using the Web Crypto API's crypto.getRandomValues() method, which provides cryptographically secure random numbers. No UUIDs are transmitted to any server, making this tool safe for generating identifiers for security-sensitive applications. You can generate up to 100 UUIDs at once, toggle between uppercase and lowercase, and remove hyphens for systems that require compact identifiers.
UUIDs frequently appear alongside other data formats in developer workflows. You might embed a UUID in a JWT token as the sub (subject) claim, validate UUID format using our Regex Tester, or store UUIDs with Unix timestamps in database records. When building APIs that return JSON responses, our JSON Formatter can help you inspect payloads containing UUID fields.
UUID Versions Explained
UUID v4 (Random)
Generated using 122 bits of cryptographically secure random data (6 bits are reserved for version and variant). UUID v4 is the most widely used version because it requires no coordination, no clock, and no network access. It's the default choice when you simply need a unique identifier. The tradeoff is that v4 UUIDs are not sortable by creation time, which can cause index fragmentation in B-tree databases.
UUID v7 (Time-ordered)
Defined in RFC 9562 (2024), UUID v7 encodes a Unix timestamp in milliseconds in the first 48 bits, followed by random data. This makes v7 UUIDs monotonically increasing over time — newer UUIDs sort after older ones. This property dramatically improves database insert performance for B-tree indexes (like those in PostgreSQL, MySQL, and SQLite) because new records always append to the end of the index rather than being inserted at random positions.
ULID (Universally Unique Lexicographically Sortable Identifier)
ULIDs encode a 48-bit millisecond timestamp and 80 bits of randomness in Crockford's Base32 format, producing a 26-character string (compared to UUID's 36 characters). ULIDs are case-insensitive, URL-safe, and sort lexicographically by creation time. They're popular in systems where string length matters or where you need human-readable sortable IDs.
Practical Examples
1. Using UUID v4 as a database primary key (PostgreSQL):
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email VARCHAR(255) NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW()
);2. Generating a UUID v4 in JavaScript:
// Modern browsers and Node.js 19+
const id = crypto.randomUUID();
// "3b241101-e2bb-4d5a-a3c0-6a1e4b7c8f9d"3. UUID v7 in Python (using uuid7 package):
from uuid_extensions import uuid7
# Time-ordered UUID — sortable by creation time
record_id = uuid7()
# UUID('018f6a1c-7b2d-7000-8a3b-4c5d6e7f8a9b')4. Validating a UUID with regex:
// Matches any UUID version (v1-v7)
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
UUID_REGEX.test("550e8400-e29b-41d4-a716-446655440000"); // true
UUID_REGEX.test("not-a-uuid"); // false5. Using ULID in a Node.js application:
import { ulid } from 'ulid';
const id = ulid();
// "01ARZ3NDEKTSV4RRFFQ69G5FAV"
// 26 chars, sortable, URL-safeWhen to Use Each Type
- UUID v4: General purpose — API keys, session IDs, correlation IDs, any case where you need a unique identifier and don't care about ordering.
- UUID v7: Database primary keys — the time-ordered property eliminates B-tree index fragmentation, improving write performance by 2-10x compared to v4 in high-throughput systems.
- ULID: When you need sortability, a shorter string representation, and URL-safe characters. Popular in event sourcing, message queues, and systems with string-based ID columns.
Frequently Asked Questions
Can two UUIDs ever be the same?
Theoretically yes, but practically no. A UUID v4 has 122 random bits, giving 5.3×10³⁶ possible values. You would need to generate about 2.71×10¹⁸ (2.71 quintillion) UUIDs before having a 50% chance of a single collision. To put this in perspective, if you generated one billion UUIDs per second, it would take about 86 years to reach that threshold. For all practical purposes, UUID collisions don't happen.
Should I use UUID or auto-increment integer for database primary keys?
It depends on your requirements. Auto-increment integers are smaller (4-8 bytes vs 16 bytes), faster to index, and simpler to debug. UUIDs are better when you need to generate IDs without database access (client-side or distributed systems), merge data from multiple databases, or hide record counts from users. UUID v7 offers a good compromise — it's sortable like auto-increment but globally unique like UUID v4. For most web applications, UUID v7 is the recommended choice for new projects.
What is the difference between UUID v4 and UUID v7?
UUID v4 is entirely random (122 bits of randomness), while UUID v7 embeds a Unix timestamp in milliseconds in the first 48 bits followed by random data. The key practical difference is that v7 UUIDs are time-ordered — they sort chronologically, which dramatically improves database index performance. UUID v4 causes random index insertions that fragment B-tree indexes over time. If you're using UUIDs as database primary keys, v7 is almost always the better choice.
Are UUIDs generated in the browser secure?
Yes, when generated using the Web Crypto API (crypto.randomUUID() or crypto.getRandomValues()). This API uses the operating system's cryptographically secure pseudorandom number generator (CSPRNG), which is suitable for security-sensitive applications. This tool uses the Web Crypto API, so the generated UUIDs are cryptographically secure. Avoid using Math.random() for UUID generation as it is not cryptographically secure.
What is a ULID and how is it different from a UUID?
A ULID (Universally Unique Lexicographically Sortable Identifier) is a 128-bit identifier encoded in Crockford's Base32, producing a 26-character string (vs UUID's 36 characters). Like UUID v7, ULIDs embed a timestamp and are sortable by creation time. The main advantages over UUID are: shorter string representation, case-insensitive, no special characters (URL-safe), and guaranteed monotonic sorting within the same millisecond. The main disadvantage is less ecosystem support compared to UUID.
Related Tools
- Password Generator — Generate cryptographically secure random passwords
- JWT Decoder — Decode tokens that often contain UUIDs as claims
- Regex Tester — Validate UUID format with regular expressions
- JSON Formatter — Format API responses containing UUID fields