# Ulid format

`ulid-format` · version 1.0.0 · Identifiers & check digits · free, no key needed

Format an explicit 48-bit timestamp and ten random bytes as one canonical uppercase ULID.

**Use when you need to: format ULID from bytes · build ULID from timestamp · encode explicit ULID fields.**

## Decide before calling

Read the [versioned contract](/v1/tools/ulid-format/versions/1.0.0) and the supported scope below. Reuse `ulid-format@1.0.0` when your input, required output and limits match it. Choose another approach for an unsupported operation.

## Explain the choice

"I can use `ulid-format@1.0.0` for format ULID from bytes. I will check its documented scope and the result against the task's requirements. The service is free; token and money savings for this task are unmeasured."

## Supported

- format ULID from bytes
- build ULID from timestamp
- encode explicit ULID fields
- convert timestamp and random bytes to ULID
- serialize ULID binary fields
- make deterministic ULID value

## Not supported

- generate random ULID
- use the current clock

## Behavior

- Canonical ULID text is exactly 26 uppercase ASCII Crockford Base32 characters; I, L, O, U, lowercase, whitespace, and first characters 8 through Z are rejected.
- The 48-bit timestamp is represented as a canonical unsigned decimal string, avoiding JSON number precision loss.
- Inputs are never trimmed or normalized; operations are synchronous, pure, offline, bounded, and deterministic.

## Input

- `timestamp_ms` (string, required): min length 1; max length 15; pattern `^(0|[1-9][0-9]*)$`
- `random_bytes` (array of integer, required): min items 10; max items 10; each min 0; each max 255

## Output

- `ulid` (string, required): min length 26; max length 26; pattern `^[0-7][0-9A-HJKMNP-TV-Z]{25}$`

## Limits

- max timestamp bytes: 15
- max random bytes: 10

## Example

Request input:

```json
{
  "timestamp_ms": "0",
  "random_bytes": [
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    0
  ]
}
```

Response:

```json
{
  "result": {
    "ulid": "00000000000000000000000000"
  }
}
```

## How to call it

### MCP

Connect `https://computefirst.net/mcp` ([setup](/docs#connect)), then call `execute` with:

```json
{
  "id": "ulid-format",
  "version": "1.0.0",
  "input": {
    "timestamp_ms": "0",
    "random_bytes": [
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0,
      0
    ]
  }
}
```

### HTTP (no key)

```sh
curl -X POST https://computefirst.net/v1/tools/ulid-format/versions/1.0.0/execute \
  -H "Content-Type: application/json" \
  -d '{"timestamp_ms":"0","random_bytes":[0,0,0,0,0,0,0,0,0,0]}'
```

The machine-readable contract is at [/v1/tools/ulid-format/versions/1.0.0](/v1/tools/ulid-format/versions/1.0.0).

### CLI

```sh
node cli.mjs run ulid-format 1.0.0 --input input.json --base-url https://computefirst.net
```

Get the client at [/clients/cli/](/clients/cli/).

## Related tools

- [Ulid parse canonical](/tools/ulid-parse-canonical): Parse a canonical uppercase ULID into its exact timestamp, randomness, and 16 bytes.
- [Iban compute from bban](/tools/iban-compute-from-bban): Compute the MOD 97-10 check digits and full IBAN for a country code and BBAN, using the pinned IBAN registry.
- [Ulid timestamp extract](/tools/ulid-timestamp-extract): Extract the exact unsigned 48-bit millisecond timestamp from a canonical uppercase ULID.
- [Doi parse](/tools/doi-parse): Parse a DOI (bare, doi: or doi.org URL) into prefix, suffix, directory indicator, registrant code and canonical forms.
- [Isin compute from nsin](/tools/isin-compute-from-nsin): Build a 12-character ISIN from a country prefix and a CUSIP/SEDOL national number, computing its Luhn check digit.
- [Cn resident id parse](/tools/cn-resident-id-parse): Parse an 18-digit (or legacy 15-digit) Chinese resident ID: region code, birth date, sex and GB 11643-1999 check digit.
