What Is a ULID? Structure, Decoding the Timestamp, and ULID vs UUID v7

Last updated: · 8 min read

A ULID (Universally Unique Lexicographically Sortable Identifier) packs a 128-bit identifier into 26 characters that sort, as plain text, in the order they were created. The first 48 bits hold Unix time in milliseconds and the remaining 80 bits are random. ULID is not an IETF or ISO standard; it is an open community specification (ulid/spec). The standardised take on the same idea is UUID version 7 in RFC 9562. This guide covers the layout of a ULID, how to read the creation time out of one, the rule for identifiers created in the same millisecond, and the mistakes that show up most often. The values in the example are real output from the ULID Generator & Decoder; generating and decoding both happen in your browser.

Formula

ULID = 10 time characters + 16 randomness characters  (26 characters, 128 bits)

Time        = Unix time in milliseconds, 48 bits     → 10 characters
Randomness  = 80 bits of cryptographic randomness    → 16 characters
Alphabet    = Crockford Base32: 0123456789ABCDEFGHJKMNPQRSTVWXYZ  (no I, L, O, U)
Each character = 5 bits;  value = Σ digit × 32^position

26 × 5 = 130 bits can be written, the id has 128 → the first character is at most 7
Largest time = 2^48 − 1 ms = 281474976710655  (ULID: 7ZZZZZZZZZ…)
Same millisecond: the randomness part is incremented by 1 (monotonic generation)

The first ten characters are a number written in base 32: reading from the left, each character's value is multiplied by 32 and added to the next, and the result is the number of milliseconds since 1 January 1970. The other sixteen characters are the random part; the tool takes those 80 bits from the browser's cryptographic generator (crypto.getRandomValues). Because the Crockford alphabet is in ASCII order, comparing two upper-case ULIDs as text gives the same answer as comparing their timestamps. When several identifiers are requested within one millisecond, the tool does not draw new random bits; it adds 1 to the previous value, so a list generated in one go is strictly increasing. When decoding, lower-case letters are upper-cased and the easily misread letters I and L are taken as 1 and O as 0.

What the inputs mean

Count
How many ULIDs to generate: a whole number from 1 to 100, 5 by default. The identifiers are produced in a single pass, so the list is in creation order. This field is ignored when the ULID field is filled in.
ULID to decode (optional)
Leave it empty and the tool generates new identifiers. Enter a 26-character ULID and it decodes that instead, showing the timestamp as ISO 8601 (UTC) and Unix milliseconds and the randomness part in hex. Leading and trailing spaces are trimmed.

Worked example: Decoding 01ARZ3NDEKTSV4RRFFQ69G5FAV

  1. Input: ULID to decode = 01ARZ3NDEKTSV4RRFFQ69G5FAV. This is the sample identifier used in the ULID specification. The first ten characters (01ARZ3NDEK) carry the time and the last sixteen (TSV4RRFFQ69G5FAV) the randomness.
  2. The Crockford values of the time characters are 0, 1, 10, 24, 31, 3, 21, 13, 14 and 19. Read in base 32, that is 1 × 32^8 + 10 × 32^7 + 24 × 32^6 + 31 × 32^5 + 3 × 32^4 + 21 × 32^3 + 13 × 32^2 + 14 × 32 + 19 = 1469922850259 milliseconds.
  3. The tool prints four lines: ULID: 01ARZ3NDEKTSV4RRFFQ69G5FAV, then Timestamp (ISO 8601, UTC): 2016-07-30T23:54:10.259Z, Unix time (ms): 1469922850259 and Randomness (80 bits, hex): d6764c61efb99302bd5b
  4. So this identifier was created on 30 July 2016 at 23:54 UTC. The tool always shows UTC; convert to your own time zone if you need local time.
  5. Tolerance for misreadings: type the same identifier with the letter O in place of the leading zero (O1ARZ3NDEKTSV4RRFFQ69G5FAV), or entirely in lower case, and the result is unchanged. The first line shows the corrected spelling.
  6. Change the last character from V to W (…G5FAW): the time stays the same and the randomness becomes d6764c61efb99302bd5c, exactly one more. That is the difference between two ULIDs generated back to back in the same millisecond.
  7. Upper limit: for 7ZZZZZZZZZZZZZZZZZZZZZZZZZ the tool shows Unix time (ms): 281474976710655, the largest 48-bit value. Make the first character an 8 (80000000000000000000000000) and you get this error instead: ULID timestamp overflow: the first character can be at most 7 (48-bit limit).
  8. A character outside the alphabet is rejected as well. With U as the last character the message reads: Invalid ULID character: U. Only Crockford Base32 is used (0–9 and A–Z; there is no U, I and L are read as 1, O as 0).

Result: 01ARZ3NDEKTSV4RRFFQ69G5FAV → Timestamp (ISO 8601, UTC): 2016-07-30T23:54:10.259Z; Unix time (ms): 1469922850259; Randomness (80 bits, hex): d6764c61efb99302bd5b

🪪 ULID Generator & Decoder

Free, no sign-up; your data stays in your browser.

Open the calculator →

How to read the result

The practical benefit of a ULID shows up in database indexes: new rows land at the end of the index, which means fewer page splits than with fully random UUID v4 keys, and sorting by id roughly gives creation order. The price is that the identifier discloses when it was created; anyone who sees a ULID can read the creation time to the millisecond. The ordering guarantee also has limits. This tool only guarantees strictly increasing values inside one generated list; identifiers produced on different servers with different clocks can land in any order within the same millisecond. Eighty random bits make collisions practically impossible, but a ULID is not a secret key or a session token, so do not let access control depend on an identifier being hard to guess.

Common mistakes

  • Storing ULIDs in lower or mixed case and then sorting them as text. The ordering guarantee holds for one spelling only; always store the canonical upper-case form.
  • Trying to decode with standard Base32 (RFC 4648). That alphabet consists of A–Z and 2–7; Crockford's starts with 0–9 and leaves out I, L, O and U. The two are not interchangeable.
  • Treating monotonic ordering as a system-wide guarantee. The add-one rule applies to a single generator; with several processes or servers, the order inside one millisecond is undefined.
  • Using the identifier as a secret. The time part is public, and with monotonic generation the next id is the previous one plus 1. For values that must not be guessable, such as password reset links, generate a separate random token.
  • Forgetting that clocks can move backwards. If a server's clock is corrected, new identifiers can sort before older ones; the timestamp reflects the clock of the machine that generated the id.
  • Assuming a ULID is a UUID v7. Both start with 48 bits of milliseconds, but UUID v7 has fixed version and variant bits; the bytes of an arbitrary ULID do not form a valid v7 UUID.
  • Trimming or padding values that are not 26 characters long. A missing character shifts both the time and the randomness; the tool rejects such input with a length error.

Frequently asked questions

What is the difference between ULID and UUID v7?

Both are 128 bits and start with a 48-bit millisecond timestamp, so both sort by time. UUID v7 is an IETF standard defined in RFC 9562, is written as 36 hexadecimal characters with hyphens, and reserves 6 bits for version and variant, which leaves 74 random bits. ULID is a community specification, is written as 26 Crockford Base32 characters, and carries 80 random bits. If your database or libraries have a native UUID type, v7 is usually the easier fit.

How do I get the timestamp from a ULID?

The first ten characters are a base-32 number giving Unix time in milliseconds. Paste the identifier into the tool's ULID field and it shows the time as ISO 8601 (UTC) and as Unix milliseconds. That time comes from the clock of the machine that generated the id.

Can two ULIDs collide?

In theory yes, in practice the chance is negligible. Within a single millisecond there are 80 random bits, that is 2^80 or about 1.2 × 10^24 possibilities. By the birthday bound you would need to generate around a trillion (10^12) identifiers in the same millisecond for the collision probability to reach 50%. A unique constraint on the primary key column is still the right safeguard.

Why are there no I, L, O or U in a ULID?

Crockford Base32 was designed for codes that people type and read aloud. I and L are easily confused with 1 and O with 0, so they were left out of the alphabet; U is omitted to make accidental words less likely. When decoding, the tool accepts I and L as 1 and O as 0, and rejects U.

Can I store a ULID in a UUID column?

Yes. A ULID is 128 bits, so it fits in 16 bytes or in a UUID type, and ordering is preserved as long as byte order is. Only the text representation changes, and the value will not carry a valid UUID version. If you store it as text, a fixed-length 26-character column is enough.

Are ULIDs sortable across servers?

To the millisecond, yes, provided the clocks agree. Inside a single millisecond the order across different generators is random, and clock drift between machines can reorder identifiers created close together. If you need a strict global order, use a database sequence or a logical clock rather than relying on the id.

Are the generated identifiers sent to a server?

No. Generating and decoding are done by JavaScript on the page, in your browser; the random bits come from the browser's cryptographic generator.

The result is not exact or binding and is for information only; it is not an official document and cannot be used in official procedures. Confirm it with the competent authority or a professional before acting; no liability is accepted for losses arising from its use.

Sources

Choose your cookie preference to continue

Records the site needs to work (theme, language, favourites) stay in your browser.

This site is free and funded by ads.

With your consent, Google Analytics cookies measure visits and Google AdSense cookies are used to show ads; the data is processed on Google servers abroad.

If you reject, the site works just the same.

Cookie Policy · KVKK notice