What is CUID2?
CUID2 is a collision-resistant identifier designed specifically for horizontal scaling and distributed systems. It's the successor to the original CUID format, rebuilt with improved security guarantees and better collision resistance.
CUID2 IDs are 24 characters long, always start with a lowercase letter (making them safe for HTML element IDs and CSS selectors), and consist entirely of lowercase alphanumeric characters. They use a combination of timestamps, counters, fingerprints, and cryptographic randomness internally, but the output is opaque by design, so no timing or ordering information can be extracted.
CUID2 vs Other Formats
| Feature | CUID2 | UUIDv4 | Nano ID |
|---|---|---|---|
| Length | 24 chars | 36 chars | 21 chars (default) |
| Starts with letter | Always | No | No |
| Character set | a-z, 0-9 | 0-9, a-f, hyphens | A-Za-z0-9_- |
| Sortable | No | No | No |
| HTML ID safe | Yes | No (starts with digit) | No (may start with digit) |
Frequently Asked Questions
- What happened to CUID (v1)?
- The original CUID was deprecated due to security concerns. CUID2 was designed from scratch with cryptographic randomness and better collision resistance. New projects should always use CUID2.
- Why does CUID2 always start with a letter?
- HTML and CSS specifications require element IDs to start with a letter. By guaranteeing a leading letter, CUID2 can be safely used as DOM identifiers without any transformation.
- Is my data sent to a server?
- No. CUID2s are generated entirely in your browser. Nothing is sent to any server.