Skip to content

UlidApi

Defined in: src/ulid.ts:124

ulid() makes one; ulid.timestamp() reads the time back out.

Lexicographic order matches time order, which is what makes a ULID sort correctly as a plain string in a database index.

const id = ulid(); // "01K39XQZP4W8YHN2VBTKD7A3RM"
ulid.timestamp(id); // 1756890764019, the millisecond it was made
// Two made in the same millisecond still sort in creation order.
ulid() < ulid(); // true

UlidApi(options?): string

Defined in: src/ulid.ts:125

ulid() makes one; ulid.timestamp() reads the time back out.

Lexicographic order matches time order, which is what makes a ULID sort correctly as a plain string in a database index.

UlidOptions

string

const id = ulid(); // "01K39XQZP4W8YHN2VBTKD7A3RM"
ulid.timestamp(id); // 1756890764019, the millisecond it was made
// Two made in the same millisecond still sort in creation order.
ulid() < ulid(); // true

timestamp: (value) => number

Defined in: src/ulid.ts:126

The generation time of a ULID, in Unix milliseconds.

string

number