Aller au contenu
uencoder

Générer ULIDs for time-sortable identifiers

ULID (Universally Unique Lexicographically Sortable Identifier) combines un timestamp avec random données, producing IDs ce trier par creation time.

  1. 1

    ULID is a 26-character string: 10 chars for timestamp (milliseconds, 48 bits) + 16 chars for randomness (80 bits). ULIDs are lexicographically sortable — sorting ULIDs as strings sorts them by creation time. This is valuable for database indexes (time-ordered), log entries, and event sourcing. ULIDs are URL-safe (Crockford Base32 alphabet: 0-9A-Z, excluding I, L, O, U).

  2. 2
    Générateur d'UUID / ULID →

    Générer a UUID for comparison. UUID v4 is random — sorting UUIDs gives no meaningful order. ULID sorts by time — useful for database primary keys where time-ordered records improve cache locality and range query performance. Use UUID for pure uniqueness; use ULID when time-ordering matters.

  3. 3
    Convertisseur d'horodatage →

    Obtenir the current timestamp to understand the ULID time component. The first 10 characters of a ULID encode the millisecond timestamp. This makes ULIDs decodable — you can extract the creation time without a database lookup. Use this for debugging and log analysis.

  4. 4
    Encodeur Base62 →

    For alternative sortable IDs, encode a timestamp + random number in Base62. This is similar to ULID but uses a larger alphabet (62 chars vs 32), producing shorter IDs. However, ULID's Crockford Base32 is more robust (no ambiguous characters) and standardized.

Questions fréquentes

ULID vs UUID for database keys?
Use ULID when you need time-ordered records (better index locality, range queries, chronological sorting). Use UUID v4 when you need pure randomness (no timing information leaked). Use UUID v7 (time-ordered, RFC 9562) as a standardized alternative to ULID. ULID is 26 chars; UUID is 36 (with hyphens) or 32 (without).
Does ULID leak timing information?
Yes — the first 10 characters encode the millisecond timestamp. This reveals when the ID was created. For most applications, this is fine (creation time is not secret). For privacy-sensitive applications (anonymous posts, medical records), use a random ID (UUID v4, NanoID) instead. You can also use ULID with a random start time (offset) to obscure the actual time.

Workflows résolvant cette tâche

Outils associés