No Login Data Private Local Save

XID Generator - Online Globally Unique ID

8
0
0
0

XID Generator

Generate globally unique, time-sortable 20-character IDs. Faster & smaller than UUID.

Click "Generate" to create an XID
Timestamp Machine ID Process ID Counter
LIVE
Batch Results
    Decode an XID
    Paste an XID to inspect its internal structure
    Unix Timestamp
    -
    UTC Time
    -
    Machine ID (hex)
    -
    Process ID / Counter
    -
    Generation History
    Generated: 0
    # XID Generated At (UTC) Copy
    No XIDs generated yet. Click "Generate" to start!
    Feature XID UUID v4
    Length 20 chars 36 chars (with dashes)
    Sortable by Time Yes No
    Storage Size 12 bytes raw 16 bytes raw
    URL-safe Yes Yes
    Database Index Friendly Excellent Good (random order)
    Frequently Asked Questions

    XID is a globally unique identifier format designed for high-performance distributed systems. It uses a 12-byte (96-bit) structure that includes a Unix timestamp, machine identifier, process identifier, and a monotonic counter — all encoded into a compact 20-character Base32Hex string. Unlike UUIDs, XIDs are naturally sortable by creation time, making them ideal for database primary keys and distributed tracing.

    XID is shorter (20 chars vs UUID's 36 chars), time-sortable (the first bytes encode the timestamp), and uses less storage (12 bytes vs 16 bytes). This makes XID more efficient for database indexing — new XIDs are appended to the end of the B-tree index rather than scattered randomly, reducing page splits and fragmentation. UUID v4 is purely random and offers no natural ordering.

    Yes, XIDs are designed to be globally unique without coordination. Uniqueness is achieved through the combination of: (1) a timestamp accurate to the second, (2) a 5-byte machine identifier (typically derived from the host's MAC address), (3) a 2-byte process ID, and (4) a 3-byte incrementing counter that can generate over 16 million unique IDs per second per process. In browser-based implementations, cryptographically strong random values substitute for machine and process IDs.

    An XID consists of 12 bytes (96 bits) organized as follows:
    Bytes 0-3: Unix timestamp in seconds (4 bytes, big-endian)
    Bytes 4-8: Machine identifier (5 bytes)
    Bytes 9-10: Process identifier (2 bytes)
    Bytes 11-13: Incrementing counter, initialized randomly (3 bytes)
    These 12 bytes are then encoded using Base32Hex into a 20-character string using the character set 0-9, a-v.

    Base32Hex encoding (character set: 0-9, a-v) was chosen because it produces URL-safe, human-readable strings without ambiguous characters. It avoids easily confused letters like 'i', 'l', 'o', and 'u', reducing transcription errors. The 20-character output is compact enough for URLs, logs, and database keys while remaining easy to copy and paste. At 5 bits per character, Base32Hex efficiently packs the 96-bit XID into exactly 20 characters.

    The 3-byte counter allows up to 16,777,216 unique XIDs per second per process per machine. Combined with the machine ID (5 bytes ≈ 1 trillion combinations) and process ID (2 bytes ≈ 65,536 combinations), the total namespace is enormous. In practice, this means an XID generator can produce millions of IDs per second without collision, making it suitable for even the most demanding distributed systems.

    Yes! The first 4 bytes of an XID encode the Unix timestamp (seconds since January 1, 1970). You can use the Decode feature on this page to paste any XID and instantly see its creation time in UTC. This is a powerful feature for debugging and tracing — you always know exactly when an XID was generated without needing a separate timestamp column in your database.

    This browser-based XID generator uses the Web Crypto API (crypto.getRandomValues) for initializing the machine ID, process ID, and counter seed. This ensures high-quality randomness for the non-timestamp components. However, XID is not designed as a cryptographic token — it is an identifier for distributed systems. If you need cryptographically secure random tokens, consider using a dedicated library or crypto.randomUUID().