--- id: python-ulid version: "4.0.1" license: MIT license_treatment: permissive maintenance: active --- # python-ulid — Universally unique lexicographically sortable identifier License: permissive · Maintenance: active · Downloads: 10.1M/mo ## What it is and what it does python-ulid is a library for creating and working with ULIDs, a 128-bit identifier format that combines a 48-bit millisecond timestamp with 80 bits of randomness. Unlike UUIDs, ULIDs are lexicographically sortable, meaning they sort correctly by creation time without additional logic. They encode to a compact 26-character base32 string (versus UUID's 36 characters) and are URL-safe with no special characters. The library provides multiple ways to generate ULIDs (from current time, from a specific timestamp, from a datetime object), convert them to various formats (string, hex, int, bytes, UUID), and extract the timestamp component. It includes customizable monotonicity policies to handle collisions when multiple ULIDs are generated within the same millisecond, optional Pydantic integration for data validation, and a command-line interface for generating and inspecting ULIDs. Use it for: - Generate sortable primary keys for database records that preserve insertion order without a separate sequence. - Create distributed IDs across multiple services without coordination, using timestamp + randomness to avoid collisions. - Replace UUIDs in APIs and URLs where a shorter, more readable identifier is preferred. - Build audit logs or event streams where IDs must be both unique and sortable by time. - Validate ULID strings in Pydantic models for API request/response schemas. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Generates and manipulates ULIDs (universally unique lexicographically sortable identifiers)—128-bit identifiers that are sortable by timestamp, more compact than UUIDs, and suitable for database keys and distributed systems. Yes. The package is actively maintained, has no known vulnerabilities, installs with minimal friction (one lightweight dependency), supports current Python versions (3.10–3.14), and solves a real problem for applications needing sortable unique identifiers. Use it whenever you need UUIDs but want sortability and compactness. ## Install pip install python-ulid uv add python-ulid poetry add python-ulid ## Installing python-ulid Before you install: Low friction: pure Python wheel with only typing-extensions as a runtime dependency. Active maintenance with a release 25 days ago and recent commits. License in practice: MIT license (permissive): you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions. Quickstart: pip install python-ulid from ulid import ULID ulid = ULID() print(str(ulid)) # e.g., '01BTGNYV6HRNK8K8VKZASZCFPE' print(ulid.datetime) # extract timestamp as datetime Requires Python 3.10 or later. Verify before relying: - Performance characteristics under high-throughput generation (monotonicity policy overhead not quantified). - Whether Pydantic integration requires the optional pydantic extra or works with core install. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 10.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags ULID generator, sortable unique identifier, UUID alternative, timestamp-based ID, distributed ID generation, lexicographic sorting identifier, base32 encoded ID, identifier-generation, database-keys, distributed-systems [View on SkillFed](https://skillfed.io/packages/python-ulid) · [View on PyPI](https://pypi.org/project/python-ulid/)