Generate KSUIDs (27-character base62, k-sortable, Segment-style layout: 4-byte timestamp + 16 random bytes). For UUIDs see UUID generator; for ULIDs see ULID generator.

IDs update automatically when you change the count.

Adjust count

Adjust the count to generate KSUIDs.

Guide: KSUID generator

↑ Back to tool

What is a KSUID?

A KSUID (K-Sortable Unique Identifier) is a 160-bit (20-byte) identifier originally created by Segment (now part of Twilio) for data infrastructure: IDs that are globally unique like UUIDs but sort naturally by creation time without a separate timestamp column — useful for high-volume event pipelines, debugging, and time-range queries. The layout matches common Segment-style libraries: 4 bytes big-endian timestamp (seconds since the KSUID epoch) + 16 bytes cryptographically random payload, then base62 encoding to 27 characters. Spoold generates KSUIDs in your browser only — no upload. For another readable overview of the format, see ksuid.net — KSUID generator.

At a glance

Summary aligned with public KSUID references (e.g. ksuid.net):

PropertyValue
Bit length160 (20 bytes)
Output length27 characters (base62)
EncodingBase62 (0-9A-Za-z) — avoids +, /, padding issues common with base64 in URLs and filenames
SortableYes — string comparison ≈ chronological order
TimestampedYes — second resolution (32-bit seconds since KSUID epoch)
MonotonicNo — same-second ordering follows random payload, not a counter
Crypto randomYes — 128 bits of randomness in the payload (here via Web Crypto)

How it works

The core idea: putting the timestamp in the most significant bytes makes lexicographic (alphabetical) string order line up with chronological order — so indexes, logs, and simple ORDER BY id behave sensibly without extra columns. The binary layout is 32-bit timestamp + 128-bit random payload (160 bits total). The timestamp counts seconds since a custom epoch (May 13, 2014 — Unix 1400000000 seconds, i.e. 1400000000000 ms) to maximize useful range in 32 bits; IDs in the same second differ only in the random suffix. Libraries can decode the embedded time from raw bytes — the base62 string does not show a clean human-visible split between “time” and “random” without decoding.

  • String length — Always 27 base62 characters for the canonical encoding.
  • Collision resistance — 128 bits of randomness per ID makes same-second collisions negligible in practice; still enforce DB uniqueness where required.
  • Not monotonic — Unlike some ULID implementations with monotonic components, typical KSUIDs are not strictly increasing within the same second beyond random ordering.

KSUID vs ULID vs UUID

KSUID vs ULID — KSUID is 160 bits total; ULID is 128 bits. ULID puts a 48-bit millisecond timestamp in the high bits and 80 bits of randomness; KSUID uses 32-bit second resolution and 128 bits of random payload — a larger entropy pool per ID at the cost of coarser time granularity. ULID’s Crockford base32 output is 26 characters (case-insensitive alphabet); KSUID’s base62 string is 27 characters and is case-sensitive. Pick ULID when you need ms ordering; pick KSUID for Segment-compatible base62 and tooling.

KSUID vs UUID v4 — UUID v4 is random and scatters across key space — good for compatibility everywhere, but no natural time order in the string. KSUID trades universal “UUID-ness” for time-clustered writes and simpler chronological scans in append-heavy workloads.

KSUID vs UUID v7 UUID v7 (RFC 9562) stays in the familiar 128-bit UUID / hyphenated hex shape and is time-sortable — excellent when databases already expect UUID columns. KSUID uses a different string format and total bit layout; choose based on ecosystem (ORMs, DB types) vs compact base62 strings.

Features

  • Batch generation1–500 KSUIDs; list updates when count changes.
  • Copy — Per-line or Copy all (newline-separated).
  • localStorage — Stores last count (spoold-ksuid-generator).
  • Crypto random — 16 random bytes from crypto.getRandomValues.

How to use

  1. Set count — 1–500 via input, slider, or ±.
  2. Copy IDs — KSUIDs regenerate when the count changes; copy one or all.
  3. Clear — Clears the list; adjust count again to regenerate.

Use cases

ScenarioWhy KSUID
Event sourcing & audit logsImmutable events with time-ordered IDs simplify replay, range queries, and materialized views.
Distributed DB primary keysNew writes cluster near “recent” keyspace vs random UUID v4 scatter — can help B-tree / LSM write patterns (workload-dependent).
Segment-compatible APIsSame string shape as many analytics and event pipelines.
Message queues & streamsNatural ordering for partitioning, dedup, and consumer logic where second precision is enough.
API resource IDsURL-safe, compact; clients can sort by ID for rough chronology without an extra field.
Fixtures & demosBatch realistic IDs for tests matching production format.

Limits

  • Time bounds — Generation uses Date.now(); values outside the KSUID representable window throw in library code (normal browser use is fine).
  • Max batch500 IDs per session.
  • Validation — This page generates IDs only; parse and validate KSUID strings in your app if you ingest user input.

People search for ksuid generator online, segment ksuid, k-sortable unique id, base62 id generator, 160 bit unique id, sortable uid golang, and ksuid vs ulid. This tool produces Segment-style 27-character strings for quick copy-paste workflows. External references: ksuid.net.

FAQ

What is a KSUID?

A K-Sortable Unique Identifier: a 160-bit value (32-bit second timestamp from the KSUID epoch + 128-bit random payload) encoded as 27 base62 characters, designed so string sort order matches creation time.

Is this compatible with Segment KSUIDs?

Encoding matches common Segment-style KSUID specs (20 bytes, base62, epoch offset). Always verify against your language library in integration tests.

How long is a KSUID string?

Always 27 characters in canonical base62 form; the underlying binary is 20 bytes.

Why 27 characters?

Twenty bytes encode to 27 base62 digits at fixed width (the numeric interpretation is left-padded in base62 space).

When should I use KSUID instead of UUID?

When you want time-ordered strings without a separate created_at for ordering, and your stack accepts non-UUID identifiers. Use UUID v4/v7 when you need RFC tooling or existing UUID columns.

Are KSUIDs unique?

Collision probability is negligible for the random portion; still enforce unique constraints in your database for correctness.

Is the KSUID generator free?

Yes. All generation happens in your browser.

Similar tools

Conclusion

Use this KSUID generator for 27-character base62, k-sortable IDs in bulk. For Crockford base32 and millisecond timestamps, use the ULID generator; for RFC-style UUIDs, use the UUID generator. Further reading: KSUID overview at ksuid.net.