UUID Generator
Generate random UUID v4 identifiers instantly. Cryptographically secure, browser-based, and free.
UUID v4 uses 122 random bits for virtually collision-free unique identifiers.
What Is a UUID and When Should You Use One?
A UUID (Universally Unique Identifier) is a 128-bit number formatted as 32 hexadecimal digits in five groups: 550e8400-e29b-41d4-a716-446655440000. The key property: any two UUIDs generated anywhere in the world at any time are virtually guaranteed to be different. No coordination needed.
Think of it like this: the total number of possible UUIDs is 2128 — roughly 340 undecillion (340 followed by 36 zeros). You could generate a billion UUIDs per second for 100 years and the probability of a collision would still be negligible. That's why databases, distributed systems, and APIs use them as primary keys.
This generator creates v4 UUIDs (random) — the most common type. Each one is generated using your browser's cryptographic random number generator, so they're suitable for production use. Generate one or many, copy, and paste into your code.
UUID Versions Compared
| Version | Based On | When to Use |
|---|---|---|
| v1 | Timestamp + MAC address | When you need time-ordering and traceability (leaks MAC address) |
| v3 | MD5 hash of namespace + name | Deterministic IDs from known input (use v5 instead — MD5 is weak) |
| v4 | Random numbers | General purpose — most common. This is what this tool generates |
| v5 | SHA-1 hash of namespace + name | Deterministic IDs where same input always gives same UUID |
| v7 (new) | Timestamp + random | Sortable by time, better database index performance than v4 |
What this means for you: Use v4 for general-purpose IDs. If you need sortable, time-ordered IDs (better for database performance), consider v7 UUIDs or ULID. If you need deterministic IDs (same input → same UUID), use v5.
UUID vs Other ID Formats
| Format | Length | Sortable | Best For |
|---|---|---|---|
| UUID v4 | 36 chars | No | General-purpose unique IDs |
| UUID v7 | 36 chars | Yes (by time) | Database primary keys |
| ULID | 26 chars | Yes (by time) | Compact, sortable alternative to UUID |
| NanoID | 21 chars (default) | No | URL-safe, compact IDs |
| Auto-increment | Variable | Yes | Single-database systems (leaks count) |
| Snowflake ID | 18-19 digits | Yes (by time) | Distributed systems (Twitter, Discord) |
UUID Practical Considerations
Database performance
Random v4 UUIDs cause index fragmentation in B-tree databases (PostgreSQL, MySQL). v7 UUIDs or ULIDs are time-ordered, so inserts are sequential and indexes stay efficient. Use v7 for high-write databases.
Storage format
Store UUIDs as native UUID type (16 bytes) in PostgreSQL, not VARCHAR(36). The text format with hyphens takes 36 bytes plus overhead. Binary storage is 2x smaller and compares faster.
Don't expose sequential IDs
Auto-increment IDs (user/1, user/2, user/3) leak information: how many users you have, when they signed up, and make it trivial to enumerate resources. UUIDs hide this.
UUIDs aren't secrets
UUIDs are unguessable but not secret. Don't use a UUID as an authentication token or session key. An attacker who intercepts a UUID can reuse it. Use proper cryptographic tokens for security.
Generating UUIDs in Code
| Language | Code |
|---|---|
| JavaScript | crypto.randomUUID() |
| Python | import uuid; str(uuid.uuid4()) |
| PostgreSQL | gen_random_uuid() |
| Ruby | SecureRandom.uuid |
| Go | uuid.New() // google/uuid |
| CLI (Linux/Mac) | uuidgen |
JavaScript's crypto.randomUUID() is available in all modern browsers and Node.js 19+. No library needed — it's built in.
Related Tools
How to use this tool
Choose the number of UUIDs to generate
Click Generate to create new UUIDs instantly
Copy individual UUIDs or all at once
Common uses
- Generating unique database primary keys
- Creating unique identifiers for API resources
- Assigning session or transaction IDs
- Producing unique file names to prevent collisions
Share this tool