Structured ID generator

A Snowflake
in 32 bits.

A 32-bit ID built from a minute, a generator number, and a slot. Small to store, easy to read, and usable offline.

32-bit integer 16 generators 128 IDs / minute 64-year range

Example · generator 5 · slot 3

01N-651B-S

Crockford Base32 + check

55,776,299 0x0353142B

Playground

Make one.

The demo runs the same code as the tests. Generate IDs, fill the eight slots, or move the clock forward.

Virtual generator

A fixed clock. State resets on refresh.

Virtual clock —
Minute number —
Ahead by 0 min

Crockford Base32 + check

—

Decimal — Hex —

Slots this minute 0 / 8
Minute—
Slot—
Encoded time—

Read it back

Decimal, 0x hex, or checked Base32.

Crockford Base32 + check

—

Decimal — Hex —

Minute—
Generator—
Slot—

Encoded time —

The demo uses memory, so state resets on refresh. A real system saves state before returning each ID.

The format

Three fields.
One number.

Time comes first, so IDs sort roughly by age. The last seven bits identify the generator and its slot in the minute.

Time

25 bits · 0–33,554,431

Whole minutes since 2026-01-01 00:00 UTC. It marks the start of the minute, not the exact millisecond.

Generator

4 bits · 0–15

One writer, not necessarily one machine. Each generator gets its own number from a central list.

Slot

3 bits · 0–7

Eight IDs per generator per minute. When they are used up, the generator moves to the next minute.

id = time × 128 + generator × 8 + slot

Worked example

From a minute
to seven characters.

Take 2026-10-30 14:32 UTC, generator 5, and the fourth slot in that minute.

01

Find the minute

435,752 minutes have passed since 2026-01-01.

02

Pick a generator

Generator 5 is 0101 in four bits.

03

Pick a slot

Slot 3 is 011 in three bits.

04

Combine the fields

435752 × 128 + 5 × 8 + 3 = 55,776,299.

Base32 is the best format for people: seven data characters plus one check character. The check only guards the written code; the 32-bit ID is unchanged. The decoder verifies it before reading the ID. Dashes are only spacing.

Correctness

Small format,
strict rules.

Uniqueness comes from how IDs are generated, not just from the number. Three rules matter most.

01

One writer per generator

Two processes with the same generator number must share one saved state. Otherwise they can issue the same ID.

02

Save before returning

State is saved before the ID leaves the generator. A crash can skip an ID, but it can never repeat one.

03

Never go backwards

If the clock moves back, the generator keeps its last minute and uses the next slot. It stops if it gets too far ahead.

Profiles

Room to grow.

SID-32 is the default. If you need larger bursts, second precision, or a signed integer, use a wider profile.

Comparison of SID-32 with wider ID profiles
Profile Width Time / gen / slot Generators Rate Range
SID-31 31 bits 25 / 3 / 3 8 64 / min ~63.8 years
SID-32 Default 32 bits 25 / 4 / 3 16 128 / min ~63.8 years
SID-32h 32 bits 20 / 6 / 6 64 4,096 / hour ~119.6 years
SID-40 40 bits 25 / 7 / 8 128 32,768 / min ~63.8 years
SID-48 48 bits 32 / 8 / 8 256 65,536 / s ~136.1 years

Only SID-32 is implemented on this page.