A ULID’s first 10 Crockford Base32 characters encode a 48-bit Unix timestamp in milliseconds, so command-line decoding suits scripts and bulk files while online decoding suits a quick one-at-a-time check.

Both methods extract the same timestamp field. Their practical differences are setup, throughput, validation, and how easily the result can be incorporated into an existing workflow. A canonical ULID contains exactly 26 characters, and its timestamp must fit within the 48-bit unsigned range. The ULID Generator provides a browser-based Decode mode that reports both the embedded millisecond value and its ISO UTC instant.

decode ulid timestamp command line vs online
Decode ULID Timestamp: Command Line vs Online

Decode a ULID in the command line

A terminal workflow is useful when the identifier already exists in a script, log, database export, or text file. The following self-contained Node.js script runs locally, requires no package, and makes no network request. It follows the field layout in the canonical ULID specification; the ULID JavaScript reference implementation is also useful when integrating ULID decoding into an existing Node.js service.

  1. Create a file named decode-ulid.js in a working directory and use a modern Node.js runtime that supports BigInt.
  2. Add these lines to the file:
    • const id = process.argv[2];
    • const alphabet = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
    • if (!id || !/^[0-9A-HJKMNP-TV-Z]{26}$/i.test(id)) { console.error("Expected a canonical 26-character ULID"); process.exit(1); }
    • const normalized = id.toUpperCase();
    • let time = 0n;
    • for (const ch of normalized.slice(0, 10)) time = time * 32n + BigInt(alphabet.indexOf(ch));
    • const max = 281474976710655n;
    • if (time > max) { console.error("Timestamp exceeds the ULID 48-bit range"); process.exit(1); }
    • console.log("milliseconds:", time.toString());
    • console.log("UTC:", new Date(Number(time)).toISOString());
  3. Run the script with the complete identifier: node decode-ulid.js YOUR_ULID.
  4. Read the milliseconds line for the raw Unix millisecond value and the UTC line for the corresponding ISO 8601 instant.
  5. For a file containing one canonical ULID per line, run while IFS= read -r id; do node decode-ulid.js "$id"; done < ids.txt. Ensure the file contains only identifiers, because blank or malformed lines will fail validation.

The script reads only the first 10 characters, maps their Crockford Base32 values, and accumulates the timestamp as a base-32 integer. Its range check also rejects a 26-character value beginning with 8 or 9 because that represents more than the permitted 128 bits. For a maintained library-based implementation, use the reference package’s decoding primitive while preserving equivalent length, alphabet, and range checks.

Decode one ULID in the browser

Use the linked ULID Generator when a quick manual inspection matters more than scripting. Generation, decoding, formatting, and copying happen in the browser, and neither the identifier nor the decoded timestamp is uploaded. The Decode control is intended for one canonical ULID at a time rather than a pasted batch.

  1. Copy the complete 26-character ULID from its source and remove any surrounding whitespace before pasting.
  2. Open the ULID Generator and choose Decode.
  3. Paste one canonical ULID into the input field.
  4. Read the displayed millisecond timestamp and ISO UTC timestamp.

The browser tool normalizes letter case for decoding and accepts only the canonical alphabet after normalization. Characters I, L, O, and U are rejected because they are excluded from Crockford Base32. Values outside the supported 128-bit and timestamp limits are also rejected rather than decoded approximately.

The product’s Generate mode is separate: it can create a monotonic batch of 1 through 100 identifiers, but that does not turn Decode mode into a bulk decoder. For many existing identifiers, the command-line loop is the more direct workflow.

Command line and online: side-by-side

The right choice depends on the number of identifiers and the surrounding system. A terminal script offers more control over batching and exit behavior, while browser decoding removes runtime setup for an occasional check.

Consideration Command-line script Browser Decode mode
Best fit Scripts, exports, log analysis, and repeatable checks A quick manual inspection of one identifier
Input volume Can process one value or loop through a file One canonical ULID per Decode action
Output Unix milliseconds and an ISO UTC instant Unix milliseconds and an ISO UTC instant
Setup Requires a local Node.js runtime and your script Requires only the browser page
Validation Checks length, alphabet, case normalization, and timestamp range Checks canonical form, character set, and supported value range
Privacy Runs locally, although files, shell history, or logs may retain identifiers Processing stays in the browser; no identifier or timestamp is uploaded
Automation Can feed results into other scripts or systems Designed for manual copying and reading

Choose the command line when you need bulk decoding, automation, or a controlled validation routine. Choose the online Decode mode when you want to paste one value and read the two timestamp forms immediately. Neither method proves when a record was originally created: it only reveals the time encoded in the supplied string.

What the decoded timestamp represents

A canonical ULID divides into two functional regions. Only the first region is needed to recover the timestamp.

Region Encoded length Meaning
Timestamp First 10 characters 48-bit Unix time in milliseconds
Randomness Final 16 characters 80-bit random component
Complete identifier 26 characters Canonical Crockford Base32 representation

The supported timestamp range is zero through 281474976710655 milliseconds. The maximum canonical string therefore begins with 7, while a 26-character Base32 value beginning with 8 or above contains more than 128 bits and is rejected. Decoding is case-insensitive after normalization, but the canonical form remains uppercase.

A displayed ISO time is in UTC. A local calendar view can show a different date or clock time because of the viewer’s time zone, while the underlying millisecond value remains unchanged. Store or compare the millisecond value when exactness matters.

Treat the decoded time as visible metadata. Because the format is public and the timestamp can be constructed independently, it is not an authenticated record of a creation event. Do not use a ULID when approximate creation time must remain hidden.

Store and compare decoded ULIDs safely

Accurate decoding depends on retaining the identifier exactly as intended. Before using the result in an application:

  1. Keep the full uppercase string; do not truncate, pad, or manually reformat it.
  2. Store it in a case-preserving 26-character field so the database does not fold or discard meaningful characters.
  3. Test the exact database collation. Lexical ordering assumes the canonical 26-character representation and ordinary bytewise or ASCII-compatible collation; case folding, locale rules, truncation, padding, or an undersized column can break the intended order.
  4. Enforce a unique constraint on the stored value and handle a conflict atomically.
  5. Do not use a check-then-insert sequence as the final uniqueness control, because another process can insert a conflicting value between those operations.

Randomness reduces collision probability but does not create an absolute uniqueness guarantee. The generator also cannot coordinate across tabs, devices, services, or identifiers created in earlier clicks, so durable uniqueness belongs in the database.

Generate a controlled test batch

When the task includes verifying identifiers produced by your own application, use the ULID Generator’s tested workflow:

  1. Choose Generate, set a quantity from 1 through 100, and create a monotonic batch.
  2. Copy the full identifiers and store them in a case-preserving field with a unique constraint.
  3. Choose Decode, paste a canonical ULID, and read its millisecond and UTC timestamp.

The initial random field comes from the browser’s cryptographic random source. Every identifier in one clicked batch uses the same captured millisecond and increments the random region by one, including carry, so the strings are strictly increasing in normal ASCII lexical order. Generation fails rather than wraps if the random field would overflow, and no identifiers or hidden state are carried across separate clicks.

A ULID remains an identifier, not a password, API key, bearer token, authorization rule, or encryption key. Use a platform’s dedicated credential mechanism and a secret manager for secrets, and avoid logging ULIDs associated with personal or confidential records.

Related reading: Epoch Converter: Decode and Encode Unix Time.

Related reading: Git Cheat Sheet: Command Line vs Online.