ULID Generator

What is a ULID?

A ULID (Universally Unique Lexicographically Sortable Identifier) is a 128-bit identifier designed to be a modern alternative to traditional UUIDs. It is 26 characters long and utilizes Crockford's Base32 character set: 0123456789ABCDEFGHJKMNPQRSTVWXYZ. Critically, it is **lexicographically sortable** because it embeds a timestamp component at its beginning.

How this ULID generator works

This tool relies entirely on client-side JavaScript and the browser's native Web Crypto API (crypto.getRandomValues) to achieve cryptographic randomness. The first 10 characters are derived from a 48-bit UNIX timestamp (millisecond precision), and the remaining 16 characters are filled with 80 bits of secure randomness.

ULID vs UUID v7

Both ULID and UUID v7 are modern, 128-bit, time-ordered identifiers designed to solve database index fragmentation. However, they differ significantly in encoding, size, and usability:

  • Compactness & Readability: A ULID is encoded using Crockford's Base32, resulting in a sleek 26-character string. UUID v7 uses standard hexadecimal, which requires 36 characters (including hyphens), making ULID more compact and easier to read or share.
  • Exclusion of Confusing Characters: The Crockford alphabet used by ULID explicitly excludes the letters I, L, O, and U to avoid visual ambiguity (e.g., mistaking 'I' or 'l' for '1', or 'O' for '0') and to prevent the accidental generation of unintended profanities. UUID hex strings do not have this safety layer.
  • Timestamp Precision & Monotonicity: ULID natively allocates 48 bits for a millisecond-precision UNIX timestamp and specifies a strict monotonicity mechanism for batch generation within the same millisecond. UUID v7 also uses a 48-bit millisecond timestamp, but its sub-millisecond sequencing methods vary between implementations.
  • 100% Storage Compatibility: Since both retain a 128-bit binary representation under the hood, a ULID can be seamlessly stored inside native UUID database columns (binary/uniqueidentifier) just like a UUID v7.

Monotonicity Guard

When multiple ULIDs are requested within the exact same millisecond, this generator automatically applies a monotonic incrementing mechanism to the random component. This guarantees that identifiers remain strictly sequential and unique, preserving their precise ordering properties even during highly intensive batch pipelines.

Common Use Cases

  • High-throughput database primary keys
  • Distributed event streams and audit logging
  • Distributed messaging queues where execution order matters
  • Clean, URL-friendly identifiers for entities

Open Source & Libraries

The core engine responsible for generating sortable identifiers behind this tool is fully open-source. You can find, use, and integrate the free IdCraft.js library on GitHub directly into your own JavaScript projects.