Anatomy of a ULID
01KA2Z8Q3R X5V6T9N4M2JHWB7C
|--------| |--------------|
timestamp randomness
48 bits 80 bits
10 chars 16 charsThe first 10 characters are the time in milliseconds since 1970, so any ULID can be turned back into a date. The first character is always 0 to 7, because 48 bits run out in the year 10889.
Checking a list of ULIDs
Paste one or more ULIDs, one per line. Quotes, commas and whitespace from JSON or SQL are ignored. Each line gets its timestamp, and problems are marked in place:
- Look-alike letters: I or L for 1, O for 0. Fixed in one click.
- Invalid characters like U, which has no safe replacement.
- Wrong length, with the missing or extra characters pointed out.
- A first character above 7, which would overflow the 48-bit timestamp.
- Lowercase, which is valid but sorts differently from uppercase as plain text.
- Duplicates and out-of-order IDs, useful when you expect a sorted list.
- UUIDs, shown in ULID form, so you can match a ULID stored in a UUID column.
ULID vs UUID
| ULID | UUID v7 | UUID v4 | |
|---|---|---|---|
| Length as text | 26 | 36 | 36 |
| Sortable by time | Yes | Yes | No |
| Random bits | 80 | 74 | 122 |
| Standard | Community spec | RFC 9562 | RFC 9562 |
| Native database type | No (store as text or UUID) | Yes | Yes |
Generating ULIDs in code
// JavaScript (npm i ulid)
import { ulid, monotonicFactory } from 'ulid';
ulid(); // 01KA2Z8Q3RX5V6T9N4M2JHWB7C
const next = monotonicFactory();
# Python (pip install python-ulid)
from ulid import ULID
str(ULID())
// Go (github.com/oklog/ulid/v2)
ulid.Make().String()Prefer the standard? The UUID generator makes time-sortable v7 UUIDs. Working with the timestamps themselves? Use the Unix timestamp converter.
Questions people ask
What is a ULID?
01KA2Z8Q3RX5V6T9N4M2JHWB7C, so IDs sort by creation time as plain strings.ULID or UUID v7?
uuid database columns. ULIDs are shorter as text (26 characters vs 36) and URL-friendly. If your database has a UUID type, v7 is usually the easier choice; you can also store a ULID in a UUID column using the “as UUID” option.