ULID Generator

Generates ULIDs (Universally Unique Lexicographically Sortable Identifiers) using the Web Crypto API, combining a 48-bit millisecond timestamp with 80 bits of randomness, encoded in Crockford's Base32. A free online tool from Staaarter, right in your browser.

Runs locallyUpdated 2026-07-25

Overview

Introduction

Random UUIDs are great for uniqueness but terrible for sort order — inserting them into a database index scatters rows randomly instead of appending them in order.

A ULID solves this by putting a millisecond timestamp first, so IDs sort chronologically as plain strings while still packing in 80 bits of cryptographically random data for uniqueness.

What Is ULID Generator?

A 26-character identifier: the first 10 characters encode the current Unix timestamp in milliseconds, and the last 16 encode 80 bits of randomness, all in Crockford's Base32 alphabet.

That alphabet uses only uppercase letters and digits, excludes visually ambiguous characters, and is fully URL-safe without any encoding.

How ULID Generator Works

The tool takes Date.now() and repeatedly divides by 32, converting the result into a 10-character Base32 string, which is enough digits to represent any millisecond timestamp until roughly the year 10889.

It then fills 16 bytes with crypto.getRandomValues() and maps each byte to a Base32 symbol — since 256 divides evenly by 32, this mapping introduces no bias.

The two parts are concatenated: timestamp first, randomness second, giving the full 26-character sortable ID.

When To Use ULID Generator

Use it for database primary keys or event/log IDs where you want both global uniqueness and the ability to sort or range-query by creation time without a separate timestamp column.

It's also a good fit for distributed systems needing roughly time-ordered IDs generated independently across many machines with no coordination.

Features

Advantages

  • Lexicographically sortable by creation time, unlike UUID v4.
  • Case-insensitive and URL-safe with no special characters to escape.
  • 80 bits of cryptographically secure randomness per millisecond keeps collisions vanishingly unlikely.

Limitations

  • The timestamp prefix reveals approximately when the ID was created, which may not be desirable for externally exposed identifiers.
  • Sort order is only guaranteed to millisecond precision — IDs created in the same millisecond sort by their random suffix, not by true creation order.

Examples

A generated ULID

Input

(no input; generated from settings)

Output

01HK8X2QZ0R9C8F3M6T7V9Y1WD

First 10 characters encode the millisecond timestamp; the remaining 16 are random.

Best Practices & Notes

Best Practices

  • Use ULIDs instead of UUID v4 whenever insertion order into a sorted index matters for performance.
  • Store ULIDs as a 26-character CHAR column, or decode them to raw 128-bit binary for maximum storage efficiency if your database supports it.
  • Generate in batches when seeding test fixtures rather than calling the tool repeatedly for one ID at a time.

Developer Notes

Byte-to-symbol mapping uses modulo 32 on a full 8-bit random byte rather than a smaller random source, which is bias-free because 256 is an exact multiple of 32 — the same property UUID v4 generation in this tool suite relies on for its character-set mapping.

ULID Generator Use Cases

  • Generating primary keys for a new database table that benefits from time-ordered inserts
  • Creating sortable event or log IDs in a distributed system
  • Producing IDs for objects in a queue where rough chronological ordering is useful

Common Mistakes

  • Treating a ULID's timestamp as an authoritative, tamper-proof creation time — nothing prevents a client from generating a ULID with a spoofed or unusual clock value.
  • Mixing ULIDs generated on machines with badly unsynchronized clocks and expecting perfect global ordering.

Tips

  • Use the lowercase option when a system's ID column is case-sensitive and you prefer lowercase for readability, but keep in mind canonical ULIDs are uppercase.
  • Sort ULIDs as plain strings — no special decoding is needed to get chronological order.

References

Frequently Asked Questions