Dev Tools••4 min read
UUID Generator Complete Guide
Generate universally unique identifiers for databases, APIs, and distributed systems. Understand UUID versions and best practices.
What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit number used to identify information in computer systems. The probability of duplicates is negligible.
550e8400-e29b-41d4-a716-446655440000
Format: 8-4-4-4-12 hexadecimal digits (36 characters total)
UUID Versions Explained
Version | Based On | Use Case |
---|---|---|
v1 | MAC + Timestamp | When creation time matters |
v3 | MD5 Hash | Namespace + name (deprecated) |
v4 | Random | Most common, general use |
v5 | SHA-1 Hash | Namespace + name |
v7 | Unix Timestamp | Sortable by creation time |
Where UUIDs Are Used
Databases
Primary keys in distributed systems
API Keys
Session tokens and API identifiers
File Systems
Unique file and object identifiers
UUID vs Other Identifiers
Type | Pros | Cons |
---|---|---|
UUID | Globally unique, no coordination | 128 bits, not human-readable |
Auto-increment | Simple, sequential | Not distributed-friendly |
Timestamp | Time-sortable | Collision risk |
Snowflake ID | Sortable, distributed | Complex setup |
Generate UUID in Different Languages
// JavaScript
crypto.randomUUID() // Built-in browser/Node.js
// Python
import uuid
str(uuid.uuid4())
// Java
UUID.randomUUID().toString()
// C#
Guid.NewGuid().ToString()
// SQL (PostgreSQL)
SELECT gen_random_uuid();
// PHP
uniqid('', true);
UUID Best Practices
- ✅
Use UUID v4 for most applications
- ✅
Store as binary(16) in databases, not varchar(36)
- ✅
Consider UUID v7 for time-ordered requirements
- ✅
Index UUID columns appropriately
- ✅
Validate UUID format before processing
Generate UUIDs Instantly
Free UUID generator with bulk generation and format options.
Generate UUIDs