explaingit

ulid/spec

10,739Audience · developerComplexity · 1/5Setup · easy

TLDR

ULID is a 26-character ID format that sorts chronologically and works safely in URLs, a practical alternative to UUID that avoids random ordering problems in databases and avoids hyphens.

Mindmap

mindmap
  root((ULID))
    What it is
      Unique ID format
      Time-sortable
      UUID alternative
    Structure
      48-bit timestamp
      80-bit random data
      Base32 encoded
    Advantages
      Chronological sort
      No hyphens
      URL-safe
    Implementations
      40 plus languages
      Python Rust Go Java
      Monotonic mode
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Replace UUIDs in a database table with ULIDs to get time-ordered inserts that reduce index fragmentation.

USE CASE 2

Generate URL-safe, human-readable unique IDs without hyphens or special characters.

USE CASE 3

Use a community ULID library in Python, Rust, Go, or 40+ other languages to generate sortable unique IDs.

USE CASE 4

Ensure IDs generated within the same millisecond still sort in creation order using ULID monotonic mode.

Getting it running

Difficulty · easy Time to first run · 5min

This is a specification only, pick a community library in your language from the README list to generate ULIDs.

In plain English

ULID stands for Universally Unique Lexicographically Sortable Identifier. This repository contains the official specification for the format, not a library itself. ULID is an alternative to UUID, the identifier format most software uses when it needs a unique ID for a database row, file, or other record. UUIDs have some practical downsides. They are 36 characters long and include hyphens, they carry no time information, and some versions require a unique network address (MAC address) that is not always available. ULID addresses these problems by packing the same 128 bits of data into a 26-character string that sorts correctly by time. Each ULID is made of two parts. The first 10 characters encode a 48-bit timestamp accurate to the millisecond. The last 16 characters hold 80 bits of random data. Because the timestamp comes first, ULIDs generated later always sort after earlier ones when sorted alphabetically. This is useful for databases where inserting records in time order reduces fragmentation and speeds up range queries. The character set used is Crockford's Base32, which omits the letters I, L, O, and U to avoid visual confusion when reading or typing IDs by hand. The result is case insensitive and safe to use in URLs without extra encoding. A monotonic mode ensures that even if multiple IDs are generated within the same millisecond, they still sort in creation order by incrementing the random portion with each call. The specification is designed to be implemented in any programming language. The README lists community-maintained implementations in over 40 languages, including Python, Rust, Go, Java, Ruby, PHP, Swift, Elixir, and many others.

Copy-paste prompts

Prompt 1
Show me how to generate a ULID in Python and use it as a primary key in a PostgreSQL table.
Prompt 2
What is the difference between a ULID and a UUID v4, and when should I choose ULID over UUID?
Prompt 3
How does ULID's monotonic mode work and why does it matter when generating many IDs in the same millisecond?
Prompt 4
My database uses UUIDs today. Walk me through migrating primary keys to ULIDs in a Node.js app with PostgreSQL.
Open on GitHub → Explain another repo

← ulid on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.