KSUID Generator

K-Sortable Unique Identifier

Generating...

About

KSUID (K-Sortable Unique Identifier) is a unique identifier that includes a timestamp component, making it sortable by creation time. It's 27 characters long, URL-safe, and contains both timestamp (32-bit Unix timestamp) and random data (160 bits). KSUIDs are useful for distributed systems where you need chronological ordering. They use Base62 encoding and are designed to be lexicographically sortable while maintaining strong uniqueness guarantees.

Use Cases

  • Distributed systems requiring time-based sorting
  • Database primary keys with chronological ordering
  • Event logging and time-series data
  • Systems requiring both uniqueness and sortability
  • K-Sortable identifier requirements
  • Applications needing timestamp-based ordering

How to Generate

Library

ksuid

NPM Package

npm install ksuid

Code Example

import KSUID from 'ksuid';
const ksuid = KSUID.randomSync();
console.log(ksuid.string); // e.g., '0ujsszwN8NRY24YaXiTIE2VwTSy'