ULID Generator and ULID to UUID Converter

Generate 1 to 20 ULIDs, each shown with the time encoded in it, or convert a ULID to the standard UUID form and back.

Runs in your browser: your files and text are not uploaded. Free, no account needed.

Last updated: · Reviewed by the QuickTooly Team

How a ULID is built

A ULID is a 128-bit value written as 26 characters of Crockford Base32:

  • Characters 1 to 10: a 48-bit Unix timestamp in milliseconds. This part makes ULIDs sort by creation time, both as text and as bytes.
  • Characters 11 to 26: 80 random bits. This tool uses the open-source ulid package, which draws them from the browser's crypto.getRandomValues.

Crockford Base32 uses the digits 0 to 9 and the letters A to Z without I, L, O and U, which avoids confusing 1 with I or L and 0 with O. The example 01ARZ3NDEKTSV4RRFFQ69G5FAV starts with 01ARZ3NDEK, which decodes to 1469922850259 ms, or 2016-07-30T23:54:10.259Z.

Sort order inside one millisecond

The ULID spec has an optional monotonic mode: IDs made in the same millisecond reuse the previous random part plus one, so they stay in creation order. This tool uses it within each batch, so the list order and the sort order are the same. Separate batches start with fresh random bits. To get the same behaviour in your own code, use the package's monotonic factory:

import { monotonicFactory, decodeTime } from 'ulid'

const ulid = monotonicFactory()
const id = ulid()
const created = new Date(decodeTime(id)).toISOString()

Converting between ULID and UUID

A ULID and a UUID are both 128 bits, so conversion only changes the notation. The converter reads the 26 Base32 characters as one number and prints it as 32 hex digits in the 8-4-4-4-12 pattern, or the reverse. Converting back gives the original value. This lets you store ULIDs in a database uuid column.

The UUID you get is not a valid version 4 or version 7 UUID, because its version and variant digits are whatever the ULID bits happen to be. Most databases store it without complaint, but a validator that checks the version will reject it.

Frequently Asked Questions

Why is my ULID rejected as invalid?

The converter accepts exactly 26 characters from the Crockford alphabet, in upper or lower case. As the Crockford spec allows, I and L are read as 1 and O as 0. U is not part of the alphabet, so a ULID containing U fails.

Why is a ULID starting with 8 or higher rejected?

The first character of a valid ULID is 0 to 7, because 26 Base32 characters hold 130 bits and only 128 are used. A first character of 8 or above would need more than 128 bits, so it cannot be converted to a UUID and the converter shows an error.

Can I read the time from a ULID I already have?

The tool shows the time only for ULIDs it generates. For an existing ULID, call decodeTime(id) from the ulid package, as in the example above.

Related Tools

  • UUID Generator - UUID v7 gives the same time ordering in the standard 36-character UUID format.
  • JWT Builder - use a ULID as the jti claim of a test token.