CUID & CUID2
Generator
Precision-engineered unique identifiers for the modern web. Generated, validated, and converted with glass-speed.
Quick CUID
Quick CUID2
All-in-One CUID Tools
Everything you need to work with CUIDs and CUID2s in one place.
CUID Generator
Generate collision-resistant unique identifiers with embedded timestamps.
CUID2 Generator
Create secure, unpredictable identifiers with configurable length.
Validator
Verify if a string is a valid CUID or CUID2 format.
Timestamp Extract
Extract the timestamp embedded in CUID v1 identifiers.
CUID Encoder
Convert any timestamp or date into a valid CUID v1.
What is CUID?
CUID (Collision-resistant Unique IDentifier) is a type of unique identifier designed for horizontal scaling and performance in distributed systems. Unlike traditional auto-incrementing IDs or UUIDs, CUIDs are optimized for client-side generation while maintaining uniqueness across multiple systems.
A standard CUID is 25 characters long and consists of:
- Prefix: Always 'c' to identify it as a CUID
- Timestamp: Base36 encoded milliseconds since epoch
- Counter: Incrementing counter to prevent collisions
- Fingerprint: Machine/process identifier
- Random: Random characters for additional uniqueness
Why CUID2?
CUID2 is the next generation of collision-resistant IDs, designed with modern security requirements in mind. Key improvements include:
- Cryptographically secure: Uses secure random number generation
- No predictable patterns: IDs don't reveal creation order
- Configurable length: Choose between 2-32 characters
- Better collision resistance: Improved entropy distribution
- Smaller default size: 24 characters vs 25 for CUID v1
Use CUID2 when security is a priority, such as for session tokens, API keys, or any scenario where predictable IDs could be exploited.
CUID vs UUID vs CUID2
Compare different unique identifier formats to choose the best one for your needs.
| Feature | CUID | CUID2 | UUID v4 |
|---|---|---|---|
| Length | 25 chars | 24 chars (default) | 36 chars |
| URL Safe | โ | โ | โ (hyphens) |
| Sortable | โ | โ | โ |
| Contains Timestamp | โ | โ | โ |
| Cryptographically Secure | โ | โ | โ |
| Configurable Length | โ | โ (2-32) | โ |
Frequently Asked Questions
Everything you need to know about CUID and CUID2 identifiers.
What is a CUID?
A CUID (Collision-resistant Unique IDentifier) is a type of identifier designed to be globally unique without requiring coordination between systems. It is a type of identifier designed to be globally unique without requiring coordination between systems. CUIDs are created using a combination of a timestamp, a counter, a client fingerprint, and random data, which ensures their uniqueness even in distributed systems.
What is CUID2, and how does it differ from CUID?
Designed with enhanced security features, CUID2 is the successor to CUID. Unlike CUID, CUID2 uses cryptographically secure random number generation and does not encode timestamps in a predictable manner. These features make CUID2 more suitable for security-sensitive applications where IDs should not be guessable or reveal the order of creation.
When should I use a CUID versus a UUID?
Use a CUID when you need a shorter identifier that is still collision-resistant and readable. CUIDs are useful for distributed systems, URLs, and mobile applications. Use a UUID when strict compliance with UUID standards is required, such as when integrating with systems that specifically require the UUID format.
Is it secure to use CUIDs in URLs?
Yes, CUIDs are designed to be URL-safe. They only contain lowercase letters and numbers, making them ideal for use in URLs, file names, and database identifiers. CUID2 adds an extra layer of security by making the IDs unpredictable.
Is it possible to extract the timestamp from a CUID?
Yes, for CUID v1, the timestamp is encoded in Base36 within the CUID structure (characters 2โ9). Our converter tool can extract and display the timestamp. However, CUID2 does not contain an extractable timestamp because it uses a different, more secure generation method.
How many CUIDs can I generate at once?
Our bulk generator can create up to 100 CUIDs or CUID2s at once. Then, you can copy all the IDs to your clipboard or download them as a text file to easily use them in your applications.
Are CUIDs suitable for database primary keys?
Yes, CUIDs are excellent primary keys, particularly for distributed databases. They don't require central coordination, can be generated on the client side, and can be roughly sorted by creation time. However, they use more storage than auto-incrementing integers (25 characters versus 4โ8 bytes).
What is the collision probability of CUIDs?
The probability of collision is extremely low. CUID uses a combination of timestamp (millisecond precision), counter, machine fingerprint, and random data to ensure uniqueness. For CUID2, the probability of a collision among 1 billion IDs is approximately 1 in 10ยนโธ.
Can I customize the length of a CUID?
CUID v1 always has a fixed length of 25 characters. However, CUID2 supports configurable lengths from 2 to 32 characters, with 24 being the default. Shorter IDs have a higher probability of collision, so only reduce length when necessary.
Is CUID compatible with all databases?
Yes, CUIDs are simple strings containing only lowercase letters (a-z) and numbers (0-9), making them compatible with virtually any database that supports string or text fields. They are compatible with MySQL, PostgreSQL, MongoDB, SQLite, and other databases.
How does CUID compare to Snowflake IDs?
Both are designed for distributed systems, but they differ in approach. Snowflake IDs are 64-bit integers that require worker ID coordination, while CUIDs are strings that can be generated anywhere without coordination. CUIDs offer greater portability, while Snowflake IDs are more compact and sortable.
Can CUIDs be used for session tokens?
For session tokens, we recommend CUID2 over CUID v1 because CUID2 uses cryptographically secure random generation and doesn't expose timestamp information. This makes it harder for attackers to predict or enumerate session IDs.
What programming languages support CUID?
You can find CUID libraries for most popular languages, like JavaScript/TypeScript (official), Python, Go, Java, C#, PHP, Ruby, Rust, and more. Check out our code examples page for more information on how to implement it in your preferred language.
How do CUIDs perform at scale?
CUIDs demonstrate optimal performance at scale due to their ability to function independently of network calls or central coordination. Generation is rapid (sub-millisecond) and can occur on any node. The combination of timestamp and counter ensures uniqueness even under high concurrency.
Should I migrate from CUID v1 to CUID2?
We recommend using CUID2 for new projects. For projects using CUID v1, migration is optional unless you are concerned about timestamp exposure. While CUID v1 is safe for most use cases, CUID2 is the officially recommended version.