Skip to content
gohacks.dev
Architecture

Snowflake ID Decoder

Decode a Snowflake ID into its timestamp, machine and sequence bits for X (Twitter), Discord, Instagram or your own epoch.

Free · No sign-up · Your inputs stay in your browser

Input

Decode a Snowflake ID

Output

2022-06-28T16:07:40.105Z

Timestamp (UTC)2022-06-28T16:07:40.105Z
Unix ms1656432460105
Datacenter / worker (5 + 5 bits)11 / 26
Sequence (12 bits)0
Binary00010101 01100101 10100001 00011111 01100010 00010111 10100000 00000000

Twitter's layout: 41 bits of milliseconds since the service's epoch, 10 bits naming the machine and 12 bits of sequence, so one machine can mint 4,096 ids a millisecond and the ids sort by time. Discord uses the same layout with its own epoch. Keep these as strings in JSON: they exceed JavaScript's 2^53 safe integers.

Runs in this browser. Nothing you paste is sent to a server.

Why services use them

Snowflakes are generated without coordination, fit in a BIGINT column and sort by time, which keeps database indexes append-only and lets an id stand in for a creation timestamp. Twitter published the design in 2010; Discord, Instagram (with its own bit layout) and many internal systems adopted variants. Discord documents its format in the developer reference.

Keep them as strings in JSON

JavaScript numbers are exact only up to 2^53, and current snowflakes are larger, so JSON.parse silently rounds them. APIs that use snowflakes send them as strings for that reason; keep them as strings, or parse with BigInt.

Share

Frequently asked questions

How do I get the date from a Discord ID?
Shift right by 22 bits and add Discord's epoch, 1420070400000 ms (the first second of 2015). Select Discord as the epoch here to do it automatically.
How many ids can one machine generate?
4,096 per millisecond with a 12-bit sequence. A generator that runs out waits for the next millisecond.
Is what I paste sent anywhere?
No. The tool runs entirely in your browser with JavaScript. Nothing you type or paste is sent to our server or stored.

Keep planning

Similar tools