ULID / NanoID generator

Batch-generate ULIDs and NanoIDs; parse ULIDs back to timestamps and UUID form; monotonic mode for DB keys.

UUID v4 wins on coordination-free uniqueness and loses on order: as a database primary key it lands randomly in B+ trees, causing page splits, and sorting by time needs an extra column. ULID exists for exactly this: 48 bits of millisecond timestamp followed by 80 bits of randomness — 128 bits total, same width as a UUID, but lexicographic order IS chronological order.

Generate ULIDs and NanoIDs in batches; randomness comes from crypto.getRandomValues (cryptographically secure). The Crockford alphabet drops I/L/O/U to survive handwriting. Paste any ULID into the parser to read its millisecond generation time and get the UUID spelling of the same 128 bits, with common mistypings (o/i/l) corrected automatically. For primary-key workloads, enable monotonic mode: IDs generated within the same millisecond are strictly increasing.

ULID structure and sortability

A ULID is always 26 characters: the first 10 encode 48 bits of millisecond time (good for about 89,000 years), the last 16 encode 80 bits of randomness, all in Crockford Base32. Because time occupies the high bits first, any system that sorts strings — ORDER BY, file listings — yields time order. That is the practical advantage over UUID v4.

When NanoID is the right pick

NanoID is the short-ID route: at 21 characters its collision odds match UUID v4, and shorter lengths suit short links, invite codes and frontend keys. It carries no timestamp and cannot be parsed. The selection rule is simple: need time-ordering, pick ULID; need short, pick NanoID; need maximal compatibility, pick UUID.

Frequently asked questions

What is monotonic mode and when do I need it?
Within the same millisecond, ordinary ULIDs carry independent randomness, so generation order does not guarantee sort order. Monotonic mode increments the previous random part within the same millisecond, guaranteeing strict increase. You need it when ULIDs are clustered primary keys and multiple rows can be written in the same millisecond.
Can a ULID be converted to a UUID?
The 128 bits map one-to-one (this tool outputs the UUID spelling). Note that UUIDs carry version and variant bit conventions — parsing a ULID as a UUID yields a nonconforming version field. The conversion suits storage layers that standardize on 16-byte columns, not protocol compatibility.
Is generation local? Can IDs collide?
Everything is generated in the browser with crypto.getRandomValues and nothing is uploaded. Collision odds live in the 2^80 random space per millisecond — negligible in engineering terms; monotonic mode rules out same-millisecond duplicates mechanically.

Related tools