Skip to main content

ULID Generator

Developer

The problem with UUID v4 is not collisions, it is ordering: random 128-bit keys scatter across a B-tree index and cause constant page splits, so writes get slower over time. ULID puts a 48-bit millisecond timestamp first and 80 random bits after it, encoded into 26 characters — time-ordered like an auto-increment key, but without a central sequence server. The alphabet also drops I, L, O and U to avoid confusion with digits.

Loading tool…

How to use

4 steps
  1. 01

    Set how many you need and press Generate again; one per line, ready for SQL, JSON or fixtures.

  2. 02

    Generating several within the same millisecond shares the first 10 characters but differs in the random tail, so ordering stays stable.

  3. 03

    Store as `CHAR(26)`; in most databases lexicographic order matches timestamp order, so `ORDER BY id` works.

  4. 04

    To recover the creation time, decode the first 10 characters as Crockford Base32.

Technical Notes & Guide

1

ULID vs UUID v7

Both lead with a timestamp. UUID v7 stays 128-bit hexadecimal with hyphens (36 characters); ULID uses Base32 to fit in 26, which is friendlier in URLs and logs. Databases support UUID natively (Postgres has a `uuid` type), while ULIDs are usually stored as text or 16 bytes. Note that ULIDs leak the creation time — if that matters, use something else.

FAQ

2 questions
Q1Can ULIDs collide?

Within one millisecond the 80 random bits would have to match exactly — about 1 in 1.2×10²⁴. Across milliseconds the timestamp differs by definition.

Q2Are they safe as session tokens?

No. 48 of the bits are a predictable timestamp, leaving 80 bits of entropy; security tokens should use 128+ bits of cryptographic randomness.

Developer