ksuid · sortable · 27 chars · base62 · local

Generate KSUIDs in bulk

K-Sortable Unique Identifiers — 4 bytes of timestamp plus 16 random bytes, base62-encoded into 27 sortable characters. Decode any KSUID back to its creation timestamp.

KSUID Generator
Count
0
5 requested
Length
27
base62
Output
0 B
bytes
Status
—
web crypto
Count:
input · decode

KSUIDs sort naturally by creation time and remain unique across machines without coordination.

output · ksuids (0)

Click Generate to mint KSUIDs

Quick Start

How to mint KSUIDs

KSUIDs combine a 4-byte timestamp (epoch 2014-05-13) with 16 random bytes, base62-encoded. The result is 27 chars and sorts naturally by time.

  1. 01

    Pick count

    1, 5, 10, 25, 100 — or any number up to 500.

    Inputs are treated as UTF-8 throughout the pipeline and validated client-side as you type — nothing dispatches until the value is well-formed.

    countinpututf-8client-sidevalidated
    count · text5 · set
    5 fresh KSUIDs
    loaded · parsedclient-side
  2. 02

    Generate

    Each KSUID embeds the current second and 128 bits of crypto randomness.

    Each toggle re-computes through a memoised hook, so flipping options never resets your input and the UI stays snappy on large inputs.

    mintoptionslivememoisedtoggles
    mint · memoisedksuid · live
    27 chars · base62
    options set · memoisedlive
  3. 03

    Sort by time

    Lexicographic order matches creation order — perfect for DB keys.

    Randomness — where used — comes from crypto.getRandomValues, never Math.random. Heavy work sits in useMemo.

    sortcomputeinstantlocaldeterministic
    sort · instantchronological · computed
    older < newer
    computed · instantinstant
  4. 04

    Decode

    Paste a KSUID below to extract its timestamp and ISO date.

    Copy writes through navigator.clipboard and downloads use a Blob — zero network traffic. Same input plus same options always yield the same bytes.

    decodecopydownloadzero-networkreproducible
    ok · copiedts · copied
    2024-08-21T…
    shipped · ready to shipsuccess
Pro tips

Pro tips for everyday utilities

Reach for crypto.getRandomValues

Cryptographically random for IDs, tokens, salts. Math.random is for animation and games, not security.

Sort IDs lexicographically

UUID v4 has no time ordering. Use ULID or UUID v7 if you need sorted IDs.

Mock data with seeds

Faker-style libraries can be seeded so tests are reproducible. Embed the seed in the fixture file.

Reference cards beat memory

Cheatsheets for Vim, Git, Docker, Linux signals are faster than man pages when you’re mid-flow.

Browser APIs vary

Touch events, gamepads, and clipboard differ across vendors. Feature-detect before use.

Persist in the right place

localStorage for user preferences, sessionStorage for transient state, IndexedDB for structured data.

Use Cases

When to use KSUIDs

Database keys, event logs, distributed systems.

Database primary keys

Sorted-by-time prevents B-tree fragmentation. Random values come from crypto.getRandomValues — cryptographically secure for tokens, salts, and session IDs. Math.random is deterministic enough for animations but predictable enough to be a security bug.

CSPRNG-backed

Event logs

Sortable IDs make tailing logs trivial. Pair with hashids, ULID, or UUID v7 when you need both random and sortable — useful for primary keys, public-facing IDs, and event log ordering without a sequence column.

reproducible

Distributed systems

Client-side generation without coordination. Output is deterministic given the same seed, so fixtures and tests stay reproducible across CI runs and contributor machines. Embed the seed in the fixture file for full replay.

snappy

API surrogate keys

Opaque IDs that don't leak counters. Heavy work runs through useMemo so the UI stays snappy on large inputs. Same input + same options yields identical bytes — the kind of stability snapshot tests rely on.

feature-detected

Event sourcing

Embedded timestamps simplify replay. Storage tools persist to the right backend: localStorage for user preferences, sessionStorage for transient state, IndexedDB for structured data. Pick the right shelf and quota worries disappear.

deterministic

Audit trails

Lexical sort = chronological sort. Browser feature detection: clipboard, fullscreen, gamepad, and Web Bluetooth APIs gracefully fall back when unavailable. No surprise white screens on Safari or older Firefox.

production-ready
FAQ

Frequently asked questions

KSUIDs sort by time; UUIDv4 is fully random. KSUIDs are 27 chars in base62 vs 36 chars in hex.
Both are time-sortable. KSUID uses base62 (URL-friendly upper+lower+digits). ULID uses Crockford base32 (case-insensitive, no I/L/O/U).
16 bytes (128 bits) of randomness per second. Collisions are astronomically unlikely.
Epoch starts 2014-05-13. 32-bit seconds → 2150 before overflow.
Yes — IDs are minted in your browser via Web Crypto. Nothing is sent to a server.
Suggest a tool

Something missing?

Tell us what you need. We ship the top requests every two weeks.

Sent straight to the maintainers · no account needed
47 in queue·8 shipped this month
Request queued. Thanks!