UUID v4 Generator - Random UUID Online
Generate cryptographically random UUID v4 identifiers. Create single or multiple UUIDs at once with formatting options.
What Is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit label used to uniquely identify objects in computer systems without requiring a central registry. Version 4 UUIDs are generated using random or pseudo-random numbers, making them the most widely used variant for general-purpose unique IDs.
A UUID v4 looks like this: 550e8400-e29b-41d4-a716-446655440000. The format is 8-4-4-4-12 hexadecimal characters separated by hyphens, totaling 36 characters (32 hex digits + 4 hyphens).
Common Use Cases for UUID v4
- Database primary keys: Replace auto-increment integers with UUIDs to avoid ID enumeration attacks and simplify distributed database merges.
- API resource identifiers: UUIDs in REST endpoints (e.g.,
/users/550e8400-e29b-41d4-a716-446655440000) prevent sequential scraping. - Session and token IDs: Secure random UUIDs as session identifiers are unpredictable and safe against brute-force guessing.
- File and asset naming: Avoid filename collisions in object storage (S3, GCS) by naming uploads with UUIDs.
- Distributed systems: Generate IDs locally on each node without coordination — no central sequence generator needed.
- Feature flags and A/B test cohorts: Stable user bucket assignment based on UUID prefix.
UUID v4 vs Other UUID Versions
| Version | Generation Method | Best For |
|---|---|---|
| v1 | Time + MAC address | Time-sortable IDs, audit logs |
| v3 | MD5 hash of namespace + name | Deterministic IDs (legacy) |
| v4 | Random numbers | General-purpose unique IDs |
| v5 | SHA-1 hash of namespace + name | Deterministic IDs from known inputs |
| v7 | Unix timestamp + random | Time-ordered, DB index friendly |
How to Generate UUIDs in Code
JavaScript / Node.js
// Browser or Node.js 19+
const id = crypto.randomUUID();
// Node.js (any version)
import { v4 as uuidv4 } from 'uuid';
const id = uuidv4(); Python
import uuid
id = str(uuid.uuid4())
print(id) # e.g. 550e8400-e29b-41d4-a716-446655440000 Go
import "github.com/google/uuid"
id := uuid.New().String() Best Practices
- Store UUIDs as
CHAR(36)or native UUID type (PostgreSQL, MySQL 8+) — not as VARCHAR to avoid wasted space. - Index UUID columns carefully: random v4 UUIDs cause index fragmentation in B-tree indexes; consider v7 or ULID for high-insert workloads.
- Never use UUIDs as secrets or tokens — they are identifiers, not secrets. Use a CSPRNG-generated random string for auth tokens.
- When passing UUIDs in URLs, lowercase is conventional. Uppercase is valid but inconsistent with most tooling.
Frequently Asked Questions
What is a UUID v4?
UUID v4 is a 128-bit identifier generated using cryptographically secure random numbers. It follows the format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx. The "4" in the third group signals the version; the first bit(s) of the fourth group are fixed per the RFC 4122 variant specification.
Are UUIDs truly unique?
The probability of a collision between two random UUID v4 values is approximately 1 in 5.3 × 1036. To put that in perspective, you would need to generate about 103 trillion UUIDs to have even a 1-in-a-billion chance of a single collision.
When should I use UUID v4 vs other UUID versions?
Use v4 for most general-purpose IDs. Use v1 if you need time-sortable identifiers that embed a timestamp. Use v5 for deterministic IDs you can reproduce from a namespace + name input. Consider v7 for database primary keys that need good index locality.
Is this UUID generator safe for production use?
Yes. The tool uses crypto.randomUUID() (or crypto.getRandomValues() as a fallback) — the browser's cryptographically secure random number generator. Generation happens entirely in your browser. No UUIDs are transmitted or logged.