CUID Generator

Collision-resistant Unique Identifier

Generating...

About

CUID (Collision-resistant Unique Identifier) is a secure, URL-safe, unique ID generator that creates identifiers optimized for horizontal scaling and performance. CUIDs are designed to be collision-resistant and include a timestamp for sorting. CUID v1 uses a combination of timestamp, counter, fingerprint (host ID), and random values to ensure uniqueness. They're 25 characters long and start with 'c' followed by a timestamp, counter, fingerprint, and random characters.

Use Cases

  • Distributed systems requiring collision resistance
  • Database primary keys with timestamp sorting
  • Horizontally scalable applications
  • Systems with multiple ID generators
  • Applications requiring high uniqueness guarantees
  • Legacy systems using CUID v1

How to Generate

Library

cuid

NPM Package

npm install cuid

Code Example

import cuid from 'cuid';
const id = cuid();
console.log(id); // e.g., 'cjld2cjxh0000qzrmn831i7rn'

Note: CUID v1 is the original version. Consider CUID2 for newer applications as it provides better performance and security.