Snowflake ID Generator - Create Unique Distributed IDs
Free Snowflake ID generator tool. Build a unique 64-bit ID from a timestamp, machine ID, data center ID, and sequence number, with a bit-level breakdown.
Snowflake ID Generator
Optional: Unix timestamp in milliseconds (defaults to current time)
Machine ID (0-31)
Data Center ID (0-31)
Sequence Number (0-4095)
Documentation
What Is a Snowflake ID Generator?
A Snowflake ID generator builds a unique 64-bit number from a timestamp, a machine identifier, and a sequence number. Twitter created the format in 2010 to give each tweet an identifier that many servers could produce at once, without ever asking each other "has this number been used yet?" This tool builds one Snowflake ID from the values you enter and shows how those values fill the 64 bits.
How This Snowflake ID Generator Works
The generator takes four inputs:
- Timestamp: a Unix timestamp in milliseconds. Leave it blank to use the current time.
- Machine ID: an integer from 0 to 31 (5 bits). This is Twitter's original "worker ID."
- Data Center ID: an integer from 0 to 31 (5 bits).
- Sequence Number: an integer from 0 to 4095 (12 bits), used to tell apart IDs created in the same millisecond.
The tool combines the four values into one 64-bit ID and displays the result split into its timestamp, machine, and sequence segments.
The timestamp is measured from a fixed starting point called the Twitter epoch: November 4, 2010, 01:42:54.657 UTC, or 1,288,834,974,657 milliseconds after the Unix epoch. This generator does not let you change that starting point — every ID it produces is measured from that one fixed date.
Snowflake ID Structure
A Snowflake ID is a 64-bit integer split into four parts, read from the most significant bit down:
| Bits | Field | Range |
|---|---|---|
| 1 | Sign bit | always 0 |
| 41 | Timestamp | milliseconds since the Twitter epoch |
| 5 | Data center ID | 0–31 |
| 5 | Machine (worker) ID | 0–31 |
| 12 | Sequence number | 0–4095 |
The leading bit is always 0, so a Snowflake ID is always a positive number. The 41-bit timestamp and 12-bit sequence field are the two parts that make Snowflake IDs useful for sorting: IDs made later have a larger timestamp segment, so they sort after earlier ones.
Snowflake ID Formula
The generator builds the ID with this formula:
1delta = timestamp - 1288834974657
2id = (delta << 22) | (dataCenterId << 17) | (machineId << 12) | sequence
3<< is a left bit shift. Shifting a number left by 22 bits is the same as multiplying it by 2²², or 4,194,304. The shift amounts (22, 17, 12) come directly from the field widths: the sequence field is 12 bits wide, so the machine ID sits 12 bits up; the machine field is 5 bits wide, so the data center ID sits 17 bits up (12 + 5); and so on.
How to Calculate a Snowflake ID: Worked Example
Suppose someone enters:
- Timestamp: 1,288,834,975,657 (exactly 1,000 ms after the Twitter epoch)
- Data Center ID: 1
- Machine ID: 1
- Sequence Number: 0
Step 1 — Find the delta. Subtract the epoch from the timestamp: 1,288,834,975,657 − 1,288,834,974,657 = 1,000.
Step 2 — Shift each field into place.
- Timestamp: 1,000 << 22 = 4,194,304,000
- Data center ID: 1 << 17 = 131,072
- Machine ID: 1 << 12 = 4,096
- Sequence: 0
Step 3 — Combine with bitwise OR. Since none of the shifted fields overlap, adding them gives the same result as OR-ing them:
4,194,304,000 + 131,072 + 4,096 + 0 = 4,194,439,168
That is the Snowflake ID for this input. The tool's result view splits the same 64-bit binary string back into a 41-bit timestamp block, a 10-bit machine block, and a 12-bit sequence block, so the shape of the number stays visible.
Where Snowflake IDs Are Used
Twitter built the format to give unique, roughly time-ordered IDs to tweets across thousands of database machines, without a central counter that every server would have to check. Discord and Instagram later adopted similar 64-bit ID designs for messages and posts. The same idea shows up in database sharding, order IDs for e-commerce systems, and event logs in distributed applications — anywhere many machines need to hand out IDs independently and still keep them roughly sorted by time.
Limitations of Snowflake IDs
A production Snowflake generator normally keeps its own running clock: it increases the sequence number for each ID made in the same millisecond and waits for the next millisecond once the sequence reaches 4,095. This tool has no memory between calculations — it builds one ID from whatever timestamp, IDs, and sequence number are entered, which makes it useful for exploring the format but different from a live production service.
The design has fixed limits, whichever service implements it:
- Fixed epoch: this generator only accepts timestamps at or after November 4, 2010 (the Twitter epoch). Earlier dates cannot be encoded.
- Timestamp ceiling: the 41-bit timestamp field runs out around July 2080. After that, the delta from the epoch no longer fits in 41 bits.
- Sequence limit: only 4,096 distinct IDs (0–4095) can be issued by one machine in the same millisecond before values would repeat.
- Machine space: with 5 bits each for machine ID and data center ID, a deployment has 1,024 distinct machine identities (32 × 32) to hand out without collisions.
- Local, not global, ordering: IDs only sort correctly against each other if they came from machines with synchronized clocks. Clock drift between machines can break strict time ordering.
History of the Snowflake ID
Twitter announced the Snowflake ID format in 2010 as a replacement for simple auto-incrementing database IDs, which do not scale across many independent database servers. The name came from the idea that, like real snowflakes, no two generated IDs are alike. The design was later open-sourced and copied, in modified form, by other large platforms that needed the same thing: unique, sortable IDs generated by many machines at once.
Frequently Asked Questions
What is a Snowflake ID? A Snowflake ID is a 64-bit number made of a timestamp, a machine identifier, and a sequence number, designed so many machines can generate unique IDs without coordinating with each other.
What is the Snowflake ID formula?
id = ((timestamp − epoch) << 22) | (dataCenterId << 17) | (machineId << 12) | sequence, where the epoch is a fixed starting date and << is a left bit shift.
Can I change the epoch in this generator? No. This tool always measures the timestamp from the fixed Twitter epoch, November 4, 2010. There is no field to set a different starting date.
Does this tool decode an existing Snowflake ID? No. It only builds a new ID from the timestamp, machine ID, data center ID, and sequence number entered, then shows the bit breakdown of that new ID.
How many Snowflake IDs can one machine generate per millisecond? Up to 4,096, since the sequence field is 12 bits wide (values 0 through 4,095).
Until what year can this generator produce valid timestamps? Until around July 2080. The 41-bit timestamp field can hold at most about 69.7 years measured from the fixed 2010 epoch, after which the value overflows the field.
References
- "Announcing Snowflake." Twitter Engineering Blog, 2010.
- "Snowflake ID." Wikipedia, https://en.wikipedia.org/wiki/Snowflake_ID