UUID vs CUID
Differences, use cases, and when to use each
UUID is the established 128-bit identifier standard (RFC 4122). CUID is a collision-resistant ID designed for horizontal scaling, with built-in timestamp for sortability and shorter string representation.
Quick Comparison
| Feature | UUID | CUID |
|---|---|---|
| Format | 550e8400-e29b-41d4-a716-446655440000 | clh9x2z5g0000356... |
| Length | 36 characters (with hyphens) | 25-30 characters |
| Sortable | Only v7 | Yes (timestamp prefix) |
| Standard | RFC 4122 (widely adopted) | No formal standard |
| Database Indexing | Poor (v4 random) | Good (time-sorted) |
When to Use Each
When to Use UUID
Use UUID when you need a standardized identifier recognized across all languages, databases, and systems. UUIDv7 adds sortability if needed.
When to Use CUID
Use CUID when you need sortable, collision-resistant IDs optimized for distributed systems, particularly in JavaScript/TypeScript applications.
Pros & Cons
UUID
RFC standard
Universal recognition
Multiple version options
Random v4 has poor index locality
Longer string
CUID
Sortable by default
Shorter representation
Optimized for databases
No formal standard
Smaller ecosystem
Verdict
UUID for interoperability and standards compliance. CUID for JavaScript applications needing sortable, database-friendly IDs. UUIDv7 bridges the gap with standardized sortable UUIDs.