ulid/javascript is a JavaScript library for generating Universally Unique Lexicographically Sortable Identifiers.
ULIDs solve the limitations of UUIDs by providing sortable, compact identifiers optimized for databases and distributed systems. The library generates 128-bit identifiers encoded as 26-character strings using Crockford's base32 encoding, making them more efficient than the 36-character UUID format. Each ULID combines a timestamp component with random data, enabling lexicographic sorting while maintaining uniqueness. The tool handles monotonic ordering correctly even when multiple IDs are generated within the same millisecond, and it automatically detects and uses cryptographically secure random number generation appropriate to the environment.
Developers should choose this library when building systems that require sortable unique identifiers, particularly for database primary keys, distributed tracing, or any application where ID ordering matters. The tool suits projects running on Node.js 18 and above or in browser environments, with support for React Native, Web Workers, and edge functions. The library provides both ESM and CommonJS entry points, ensuring compatibility across different module systems. Beyond basic ID generation, it offers seed time functionality for migrations from other ID schemes, monotonic counter creation for guaranteed ordering, and validation and decoding utilities for working with existing ULIDs.
The project maintains active development with regular updates addressing compatibility across diverse JavaScript environments. The test suite is comprehensive and can be run with standard npm commands. Performance benchmarking is built into the development workflow, allowing contributors to measure the impact of changes. The library provides a command-line interface accessible both through global installation and via npx, supporting batch generation of multiple IDs. Documentation includes detailed usage examples for all major features, from basic generation to advanced scenarios like custom pseudo-random number generators.