Generate CUID2 IDs, Built for Database Primary Keys
This cuid2 generator creates CUID2 identifiers, a horizontally scalable id generator format designed specifically to hold up under real database workloads: safe to generate across distributed systems with no central coordination, collision resistant at high generation volume, and safe to insert directly as a primary key without a separate auto-increment counter. Unlike a sequential integer ID, a CUID2 can be generated on the client before a row is even written to the database, useful for optimistic UI updates and offline-first apps that need a real ID immediately.
How to Use This CUID2 Generator
Set Count to how many IDs you need (1 to 100 per request) and Length to how many characters each one should be (4 to 32, default 24). Click Generate to generate cuid2 output instantly, then copy the list or download it as a text file.
CUID2 vs UUID: What's Actually Different
The cuid2 vs uuid comparison matters most for database primary keys specifically, here's where they diverge:
| CUID2 (default) | UUID v4 | |
|---|---|---|
| Length | 24 characters (configurable) | 36 characters (with hyphens) |
| Starts with | Always a letter | Any hex digit (0-9, a-f) |
| Case | Lowercase only | Lowercase (canonical) |
| Sortable | No, and deliberately not sequential to avoid predictability | No, fully random |
| Designed for | Database primary keys specifically | General-purpose unique identifiers |
Why Prisma and Other ORMs Use CUID2
This secure random id generator format is a common choice for a prisma default id generator setup: Prisma supports CUID2 natively via the `@default(cuid(2))` field attribute in schema.prisma, and the ORM's docs now steer new projects toward it, the original cuid() function is deprecated in favor of cuid2 for security reasons (the original CUID design had a theoretical predictability weakness that CUID2's design specifically addresses). If your ORM or framework already expects a CUID2-shaped string, generating a batch here to seed test data or inspect the format is faster than spinning up a full local database.