Details
Universally Unique Lexicographically Sortable Identifier (ULID) is a unique identifier that is lexicographically sortable and is intended as an improvement over UUID.
ULIDs have the following properties:
- Lexicographically sortable (useful for database indexing)
- Canonically encoded as a 26 character string, as opposed to the 36 character UUID
- Uses Crockford's base32 for better efficiency and readability (5 bits per character)
- Monotonic sort order (correctly detects and handles the same millisecond)
- 128-bit compatibility with UUID
- 1.21e+24 unique IDs per millisecond
- Case insensitivity
- No special characters (URL safe)
ULID Structure:
- First 10 characters: timestamp (milliseconds since Unix Epoch)
- Last 16 characters: random values
While the probability of generating the same ULID is extremely low, for all practical purposes, you can assume it is unique and non-repeatable.