A globally unique ID generator for the web, using a 12-byte Mongo Object ID algorithm with a compact base32hex string representation.
xid is a globally unique ID generator library for Go, based on the Mongo Object ID algorithm. It produces compact, sortable 12-byte identifiers with a 20-character base32hex string representation, designed for web and server applications without requiring configuration or central coordination.
Go developers building distributed systems, web services, or databases who need efficient, sortable unique identifiers without setup overhead.
Developers choose xid for its balance of small size, built-in sortability, and zero-configuration design, offering better performance and simplicity compared to UUIDs or Snowflake-like systems.
xid is a globally unique id generator thought for the web
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
At 12 bytes binary and 20 characters string, it's smaller than UUIDs (16 bytes, 36 chars), reducing storage and bandwidth overhead as highlighted in the comparison table.
K-ordered with 1-second precision time embedding, enabling chronological sorting without extra database fields, based on the Mongo Object ID algorithm.
Works out-of-the-box without machine/data-center IDs or central servers, simplifying deployment in distributed systems as noted in the philosophy.
Avoids global locks used in UUIDv1/v2, ensuring better concurrency and speed, with benchmarks showing faster generation than UUIDs in multi-CPU environments.
Uses base32hex for case-insensitive, sortable string representation that is web-friendly and avoids issues with non-alphanumeric characters in transports.
IDs are predictable due to reliance on system time and a monotonic counter, making it unsuitable for security-sensitive use cases, as admitted in the notes.
Limited to 1-second granularity, which may not suffice for applications requiring millisecond or microsecond accuracy in ID timestamps.
Guarantees only up to 16,777,216 unique IDs per second per host/process; high-scale systems could exhaust this, risking collisions under extreme load.
Primarily a Go library, and while ports exist for other languages, they may lack the same maturity, documentation, or community support, limiting cross-platform adoption.