CUID generator — cuid2-style IDs that start with a letter

Choose a length and the tool makes cuid2-style IDs, lowercase letters and digits that always begin with a letter, built by hashing the time, fresh random data and a counter so nothing about when or where they were made shows through.

Live demo · real result from this tool

Press Generate to create a result.

Processed on your device — nothing is uploaded.

How to use the CUID generator

  1. Set the Length, from 2 to 32 characters. The default of 24 matches cuid2’s default.
  2. Set How many IDs, from 1 to 500.
  3. Press Generate and copy the list.

What it does and when to use it

cuid2 is a popular choice for database primary keys and public record IDs in JavaScript projects. They are a good fit when you want IDs that are hard to guess, safe to show in URLs, free of upper case (so they survive case-insensitive systems) and never start with a digit.

Use this page to create IDs for seed data and fixtures, to test that your validation accepts the format, or to see how a shorter length looks. If you want time-sortable IDs, the ULID generator or the UUID generator with version 7 is a better match. For a plain random ID with a collision estimate on screen, try the Nano ID generator.

How it works

For each ID the tool:

  1. Picks a random lowercase letter for the first character.
  2. Builds an input string from the current time in base 36, a fresh random base-36 string as long as the ID, a counter that starts at a random value and goes up by one per ID, and a 32-character random fingerprint shared by the batch.
  3. Hashes that string with SHA3-512, writes the hash in base 36, and keeps enough characters to reach the chosen length.

All random parts come from crypto.getRandomValues. The length sets an upper limit on strength: with 36 possible characters, a 24-character ID can hold at most about 124 bits, and a 10-character ID at most about 51 bits.

Worked examples

  • Default length. Length 24 gives IDs such as z8m01lopqq86ngxsv40o60np and at3srcofghtnf9q6ky0giof2, followed by the note “Built like cuid2 … Not byte-compatible with any one library.”
  • Short IDs. Length 10 gives values such as wauuslt5xg. That is handy for a demo, but at about 51 bits it is too short for a large table.

Limits and tips

  • Lengths under about 16 raise the risk of duplicates in big datasets. Keep a unique index on the column either way.
  • IDs are lowercase only. Do not upper-case them later, or they will no longer match.
  • A cuid is an identifier, not a secret. Do not use one as a password or an API key.

Frequently asked questions

What is the difference between cuid and cuid2?
The original cuid put a timestamp, a counter and a machine fingerprint into the ID almost as plain text, so anyone could read when and roughly where it was made. Its authors later deprecated it, citing security concerns. cuid2 runs those inputs, plus random data, through SHA3 and keeps only the hash, so the ID reveals nothing.
Will these IDs match the @paralleldrive/cuid2 package exactly?
They follow the same recipe and look the same (24 lowercase characters by default, first character a letter), but the exact inputs to the hash differ, so the tool says they are not byte-compatible with any one library. That does not matter in practice; no system checks a cuid against a formula.
Why does every ID start with a letter?
So it is always safe as an HTML id, a CSS selector, a variable name or a key in systems that reject identifiers beginning with a digit.
Can I sort cuid2 IDs by creation time?
No. The hash scrambles the timestamp. If you need IDs that sort in time order, use ULIDs or version 7 UUIDs.
Does the tool download anything?
The SHA3 code comes from the hash-wasm library, which is loaded as part of this site the first time you press Generate. Your IDs are made on your device and not sent anywhere.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close