Skip to content
UniKit

Snowflake ID generator & decoder

Generate 64-bit Snowflake ids (41-bit ms timestamp + 10-bit worker + 12-bit sequence) in batches — set the start timestamp, epoch, worker id, start sequence and step, with automatic millisecond carry so ids stay strictly increasing. Decode existing ids back into time, worker and sequence, all locally.

Runs in your browserEvery computation happens in your browser — your data never leaves this device.

Layout is 41-bit timestamp + 10-bit worker + 12-bit sequence. The timestamp is the millisecond offset from the epoch and must be ≥ epoch; the default epoch is Twitter's 1288834974657 (2010-11-04T01:42:54.657Z).

Generated ids

Ids in one batch increase strictly: when the sequence overflows, the timestamp advances by 1 ms and the sequence restarts at zero, as the Snowflake spec does. The same seed reproduces the batch exactly.

1724551110456253804
1724551110456253805
1724551110456253806

Ids: 3 · Worker: 1 · Sequence: 3436 → 3438 · Seed: demo

Decode a Snowflake id

Paste an id to recover its timestamp, worker and sequence (shown in UTC).

UTC time: 2023-11-14T22:13:20.000Z · Worker: 1 · Sequence: 0 · Timestamp: 1700000000000

What this tool does

  • Produce distributed ids for test data, separated by worker id and timestamp so primary keys never collide
  • Decode a Snowflake id captured in production to see its write time, worker id and per-millisecond sequence

Example

Input

start timestamp 1700000000000, worker 1, count 3, seed demo

Output

1724551110456253804
1724551110456253805
1724551110456253806

The starting sequence comes from the seed (3436 here), so the three ids use 3436, 3437 and 3438. Another seed picks another start but the batch still increases strictly.

Frequently asked questions

What is the bit layout, and why is the timestamp relative?

It follows Twitter Snowflake: one sign bit fixed to 0, 41 bits of millisecond timestamp, 10 bits of worker id and 12 bits of sequence. The stored timestamp is the offset from the epoch, which defaults to Twitter's 1288834974657 (2010-11-04T01:42:54.657Z), so changing the epoch changes the time a given id decodes to.

What happens when many ids fall in the same millisecond?

Within one millisecond the 12-bit sequence increments from 0 to 4095; when it overflows the timestamp advances by 1 ms and the sequence restarts at zero, so a batch stays strictly increasing and duplicate-free. The result reports whether a sequence wrap happened.

Does it read the system clock?

No. The pure function never reads the clock — you supply the start timestamp (the field defaults to 1700000000000). The same options and seed therefore produce identical output on any machine at any time, which keeps tests and bug reports reproducible.

Does decoding work for other Snowflake variants?

Decoding assumes the standard 41 + 10 + 12 layout with a millisecond offset from the epoch. Variants with different bit widths (Sonyflake, for example) or a custom width/epoch will decode incorrectly — set the matching epoch and double-check the layout before trusting the result.

Keywords:snowflake idworkerIdTwitter snowflakeid generatorsequence

Related tools