ULID generator
Generate, parse and validate ULIDs: a 48-bit millisecond timestamp plus 80 random bits, Crockford Base32 encoded into 26 characters that sort by time.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
The first 10 characters of a ULID hold the millisecond timestamp, so plain lexicographic sorting is chronological sorting; within one batch the random part increments, so the output is already ordered.
Alphabet 0123456789ABCDEFGHJKMNPQRSTVWXYZ (no I, L, O or U); the first character is at most 7.
01ARZ3NDEKTSV4RRFFQ69G5FAV
Parse a ULID
14699228502592016-07-30T23:54:10.259ZTSV4RRFFQ69G5FAVWhat this tool does
- Use them for database primary keys, log IDs and order numbers: ULIDs sort lexicographically in time order, so B-tree inserts stay local instead of scattering like random UUIDs.
- Generate ordered IDs for one millisecond in a batch: the random part increments, so the output is already sorted without a separate timestamp column.
- Find out when an ID was created: parse the 26 characters back into a millisecond timestamp and UTC time when you need to know how old a record is.
- Validate IDs that come from elsewhere by checking length, alphabet and the first character, catching hand-typed mistakes.
Example
Input
01ARZ3NDEKTSV4RRFFQ69G5FAV
Output
Timestamp (ms): 1469922850259 Time (UTC): 2016-07-30T23:54:10.259Z Random part: TSV4RRFFQ69G5FAV
This is the canonical example from the ULID spec. The first 10 characters 01ARZ3NDEK hold the timestamp and the last 16 are random; ULIDs are case-insensitive and are normalised to upper case when parsed.
Frequently asked questions
How is a ULID different from a UUID, and which should I use?
A ULID is 26 Crockford Base32 characters: readable, hyphen-free and sortable as plain text in time order. UUID v4 is 36 random characters with no ordering; UUID v7 is also time-ordered but longer. Pick ULID or v7 for sortable keys, and UUID when maximum compatibility matters.
Why are I, L, O and U missing from the alphabet?
That is the Crockford Base32 design: I and L look like 1, O looks like 0, and U is dropped to avoid accidental profanity. Case is ignored when parsing too, so copying by hand or reading an ID aloud rarely goes wrong.
Why can the first character only be up to 7?
The first 10 characters carry a 48-bit timestamp left-aligned into a 50-bit space, so the top two bits must be zero and the first character stays within 0–7. That is also part of validation: a first character above 7 is not a valid ULID.
Can two IDs generated in the same millisecond collide?
In a batch, all IDs share the timestamp and the random part increments from one random starting point, so they are unique and already sorted. Across batches the 80 random bits protect you — you would need on the order of 2^40 IDs before a 50% chance of a collision.
Where does the randomness come from?
From the browser’s crypto.getRandomValues, a cryptographically secure source. Nothing is uploaded or written to disk and no server is involved. If crypto is unavailable the tool throws instead of silently falling back to insecure Math.random.
Keywords:ulidcrockfordbase32sortable id时间有序唯一 id生成解析排序