CUID2 Validator
Verify if a string is a valid CUID2 format. Supports variable-length identifiers from 2 to 32 characters.
CUID2 Format Specification
CUID2 has a simpler format than CUID v1, but with important security improvements:
- First character: Any lowercase letter (a-z)
- Remaining characters: Lowercase letters (a-z) and numbers (0-9)
- Length: Variable, default 24 characters (configurable 2-32)
- No predictable patterns: Cryptographically secure randomness
Example Valid CUID2s
Example Invalid Strings
TZ4A98XXAT96IWS9ZMBRGJ3AUppercase not allowed4z4a98xxat96iws9zmbrgj3aMust start with letter, not numbertz4a98xx-at96-iws9-zmbrNo hyphens allowedCUID vs CUID2 Comparison
| Feature | CUID | CUID2 |
|---|---|---|
| First character | Always 'c' | Any letter (a-z) |
| Length | Fixed 25 | Variable 2-32 (default 24) |
| Structure | Predictable components | Random (no pattern) |
Frequently Asked Questions
What are the rules for a valid CUID2?
A valid CUID2 must begin with a lowercase letter (a-z) and contain only lowercase letters and numbers. The default length is 24 characters, but the CUID2 can be configured to generate IDs between two and 32 characters long.
In what ways is CUID2 validation different from CUID?
A CUID always starts with a "c" and is exactly 25 characters long. CUID2 can start with any lowercase letter and can be any length (typically 24 characters, but it can range from 2 to 32). CUID2 does not have the predictable structure that CUID has.
How can I tell if a string is CUID or CUID2?
If it starts with "c" and has 25 characters, it could be CUID or CUID2. However, if it starts with a different letter or is not 25 characters long, it is likely CUID2 or invalid. Use the appropriate validator for each type.
What causes a CUID2 validation to fail?
Some common reasons include containing uppercase letters, special characters (such as hyphens and underscores), starting with a number instead of a letter, containing spaces, or being empty.