KSUID Generator

Generator

Generate K-Sortable Unique Identifiers (KSUID) — 27-character base62 IDs with an embedded, sortable timestamp. Runs entirely in your browser.

Options
KSUIDs
Click Generate to create one or more KSUIDs

About this tool

About KSUID Generator

KSUID (K-Sortable Unique Identifier) is an identifier format created by Segment that combines a timestamp with random bits so that IDs generated later always sort after IDs generated earlier — useful for event logs, database keys, and anything that benefits from roughly chronological ordering without a central counter. A KSUID is 160 bits total: a 32-bit timestamp (seconds since a custom epoch of 2014-05-13) followed by 128 bits of randomness, encoded as 27 base62 characters.

This generator packs the current time (or your custom timestamp) into 4 bytes, generates 16 cryptographically random bytes, concatenates them into a 20-byte payload, and encodes the result as base62 (digits, then uppercase, then lowercase letters), left-padding to exactly 27 characters. Each generated KSUID is decoded back to show its embedded timestamp and random hex, so you can confirm the encoding round-trips correctly.

Use this to generate test KSUIDs for event-tracking systems, append-only logs, or any database schema that uses KSUIDs as primary keys, to understand how the timestamp is embedded in the ID, or to generate a batch of realistic-looking sortable IDs for seed data.

Instant generation entirely in your browser using cryptographically random bytes for the non-timestamp portion. Because the timestamp is embedded directly in the ID, KSUIDs generated later will always sort lexicographically after ones generated earlier — no coordination between servers required.

Key Features

  • Generates 1-1,000 KSUIDs at once
  • Always exactly 27 base62 characters, zero-padded
  • Shows the decoded timestamp and random hex for each generated KSUID
  • K-sortable — later-generated IDs always sort after earlier ones
  • One-click copy for individual IDs or the whole batch
  • 100% browser-based, no data ever transmitted

FAQ

KSUID Generator — Frequently Asked Questions

What is a KSUID?

KSUID stands for K-Sortable Unique Identifier, created by the analytics company Segment. It embeds a timestamp directly in the ID, so IDs sort chronologically when sorted as plain strings — without needing a database auto-increment column or coordination between multiple servers generating IDs concurrently.

Why does KSUID use a custom epoch instead of the Unix epoch?

The custom epoch (1,400,000,000 Unix seconds, or 2014-05-13) shifts the usable timestamp range forward. Since the timestamp is only 32 bits, starting from the Unix epoch (1970) would run out of range decades sooner than starting from a more recent date — the custom epoch extends how far into the future KSUIDs remain valid.

KSUID vs ULID vs UUID v7 — what's the difference?

All three embed a timestamp for sortability, but differ in details: KSUID uses a 32-bit second-precision timestamp and 128 bits of randomness, encoded as base62 (27 chars). ULID uses a 48-bit millisecond timestamp and 80 bits of randomness, encoded as Crockford base32 (26 chars). UUID v7 uses a 48-bit millisecond timestamp and 74 bits of randomness within the standard UUID hex format. ULID and UUID v7 offer millisecond precision; KSUID only offers second precision but has more random bits.

Can I decode the timestamp back out of a KSUID?

Yes — this generator shows the decoded timestamp and random hex right next to each generated KSUID, since the encoding is fully reversible: base62-decode the string back to 20 bytes, and the first 4 bytes are the timestamp offset from the KSUID epoch.

Tips

  • KSUIDs sort correctly as plain strings — no need to parse them first if you just need chronological ordering
  • The timestamp only has second-level precision — if you generate many KSUIDs within the same second, their random portion (not the timestamp) determines their relative order
  • Generate a batch of 1,000 at once if you need realistic-looking seed data for a database that uses KSUID primary keys
  • This generator never sends anything to a server — every KSUID is built entirely in your browser

Explore more

Related Tools

Other tools that might be useful for your workflow