Skip to content

Efficient CUID Generator for Unique Identifiers in Systems

Generate a collision-resistant CUID2 unique identifier instantly in your browser. Free tool for database keys, distributed systems, and web applications.

CUID Generator

Generate a collision-resistant ID quickly and easily.

Enter a value to see results
Loading calculator...
📚

Documentation

What Is a CUID?

A CUID (collision-resistant unique identifier) is a short string of letters and digits used to label a record, file, or event so that no two items share the same name. This tool generates CUID2, the current version of the format, using the @paralleldrive/cuid2 library. Each id is 25 characters long, contains only lowercase letters and digits, and is created entirely in the browser — nothing is sent to a server.

How to Use This CUID Generator

  1. Click Generate New CUID to create an id.
  2. Click Copy to Clipboard to copy it.
  3. Paste the id into a database, file name, or application.
  4. Click generate again for another id. Collisions between separate CUID2 values are extremely unlikely, though not mathematically impossible.

The generated id is also stored in the page's URL, so a link to the result can be shared or bookmarked.

CUID2 Structure and Formula

A CUID2 is built like this:

1id = randomLetter + base36( SHA3-512( time + entropy + counter + fingerprint ) ).substring(1, length)
2

The hash function mixes four private inputs — the current time, a per-session counter, a fingerprint of the host machine, and random entropy — and runs them through SHA3-512. The result is converted to base 36 (digits 0-9 and letters a-z) and cut down to the requested length, 25 characters by default.

Only the first character stands on its own: a random letter placed at the front so every id begins with a letter rather than a digit. Many systems, such as SQL table and column names, require identifiers to start with a letter, so this makes a CUID2 safe to use as a name almost anywhere. Every character after that first letter is part of one continuous, opaque hash body — it has no separate sections.

Because the hash only goes one way, none of its inputs can be pulled back out of the finished id. A CUID2 has no recoverable timestamp, no recoverable counter, and no recoverable fingerprint. This is a deliberate privacy and security choice: an id alone cannot reveal when or where it was created.

Example

Generating an id with this tool might produce:

1vcpuhcj51eomj1o31dnlqopu0
2

Here v is the random leading letter, and cpuhcj51eomj1o31dnlqopu0 (24 characters) is the hash body. The two parts look different only because the first character is guaranteed to be a letter — the hash body can contain a mix of letters and digits.

Why Systems Use CUID2

  • No coordination needed. Any machine can generate a valid id on its own, without asking a central server or database for the next value.
  • Collision resistance. The mix of time, counter, host fingerprint, and random entropy makes it extremely unlikely that two machines produce the same id, even when generating many ids per second.
  • URL-friendly. A CUID2 uses only lowercase letters and digits, so it never needs to be encoded for use in a web address.
  • Fast, private generation. Because this tool runs the generator in the browser, ids are created instantly and never leave the device.

CUID2 ids are not sortable by creation time. Unlike a database auto-increment number, or the older CUID (version 1) format, a CUID2 hides its timestamp inside the hash instead of storing it in plain view. Applications that need to sort records by creation order should store a separate timestamp column alongside the id.

CUID2 vs. UUID vs. Auto-Increment IDs

FeatureCUID2UUID v4Auto-increment
Length25 characters36 characters (with hyphens)Varies (usually a short number)
Character setLowercase letters and digitsHex digits and hyphensDigits
Needs central coordinationNoNoYes (a database sequence)
Sortable by creation timeNoNoYes
URL-friendly without encodingYesRequires care around hyphensYes

CUID2 and UUID v4 solve the same problem — generating ids without central coordination — but CUID2 is shorter and uses a smaller character set, which makes it easier to read and paste into a URL.

Common Uses

  • Primary keys in distributed databases, where multiple servers insert rows independently
  • Request or trace ids used to follow one action across several microservices
  • File names for uploads, so two files never overwrite each other
  • Session or token ids for web applications
  • Message ids in queues such as Kafka or RabbitMQ

A Short History

The original CUID format was released by Eric Elliott in 2012 as an alternative to UUIDs for distributed applications. CUID2, published by the same Paralleldrive project, redesigned the format around a cryptographic hash and removed the recoverable timestamp and counter that the original version exposed. This tool generates CUID2 ids only.

Frequently Asked Questions

What is the difference between CUID (v1) and CUID2? CUID v1 stored a visible timestamp and counter inside the id, which made ids sortable but also leaked when and how many ids had been created. CUID2 replaces those visible fields with a one-way hash, so no information can be read back out of the id.

Are the CUIDs from this tool sortable by creation time? No. A CUID2 has no recoverable timestamp, so ids cannot be ordered by when they were generated just by looking at the string.

How long is a generated id, and can the length be changed? This tool always generates 25-character ids. There is no option in this tool to request a different length.

Can two different machines generate the same CUID2 at the same time? It is possible in theory but extremely unlikely in practice. Each id mixes a host-specific fingerprint with random entropy, so independent machines are very unlikely to ever produce the same hash.

Does this tool send any data to a server? No. The id is generated by JavaScript running in the browser using the local system clock and browser-provided randomness. Nothing is transmitted.

Can I use a CUID2 as a database primary key? Yes. CUID2 ids work well as primary keys in distributed databases, since any node can generate one without checking with a central sequence. They are not naturally sorted by insertion time, so an application that needs that order should keep a separate created_at column.