cuid generates short unique strings for databases and HTML IDs. The maintainers deprecate it in favor of Cuid2 because timestamps in IDs raise security concerns.
Overview
cuid is a JavaScript-oriented identifier scheme that returns compact random-looking strings safe for HTML element IDs and server-side unique keys. Each ID combines a leading marker, timestamp, counter, client fingerprint, and random material to reduce collision risk across processes and hosts.
The format is designed for horizontal scaling: multiple clients can create IDs without a central database sequence, and IDs from one machine tend to increase over time for index-friendly ordering. Implementations exist for Node, browsers, and several other languages through community ports.
The project documentation explains trade-offs versus UUIDs and warns that monotonic and timestamp-based IDs can leak ordering or timing. It also notes that cuids are not marketed as cryptographically secure secrets.
Repository status marks the original cuid specification as deprecated and directs new work to Cuid2, which addresses the stated security issues while keeping similar goals around collision resistance and offline generation.
Key features
- Compact collision-resistant IDs
- Timestamp and counter components
- Client fingerprint entropy
- Browser and Node implementations
- Monotonic ordering per process
- Short slug variant for URLs
- Multi-language ports
Use cases
- Client-generated database keys
- HTML element identifiers
- Offline-capable unique IDs
- Legacy apps still on cuid format