Snowflake ID is a 64-bit time-ordered identifier format created by Twitter in 2010 for generating unique IDs at scale without a centralized sequence generator. It has since been adopted and adapted by Discord, Instagram (with a different epoch), and many other services.

Snowflake ID bit layout

63                                                               0
┌────────────────────────────────────────────────────────────────┐
│  41-bit timestamp (ms since custom epoch)  │ 10-bit │ 12-bit   │
│                                            │machine │sequence  │
└────────────────────────────────────────────────────────────────┘
FieldBitsDescription
Sign bit1Always 0 (positive integer)
Timestamp41Milliseconds since custom epoch (e.g. 2010-11-04)
Machine ID10Datacenter (5 bits) + worker (5 bits)
Sequence12Up to 4096 IDs per millisecond per machine

UUID v7 bit layout comparison

127                                                               0
┌────────────────────────────────────────────────────────────────┐
│  48-bit Unix ms timestamp  │ ver │  rand_a  │ var │  rand_b    │
│                            │  4b │  12 bits │ 2b  │  62 bits   │
└────────────────────────────────────────────────────────────────┘
FieldBitsDescription
Timestamp48Unix milliseconds since 1970-01-01
Version4Always 0b0111 (version 7)
Random A12Random bits
Variant2Always 0b10
Random B62Random bits
Total random74No machine ID required

See UUID Bit Fields for the full v7 layout.

Key differences

PropertySnowflake IDUUID v7
Size64 bits (BIGINT)128 bits (UUID)
CoordinationMachine ID registry requiredNone — 74 random bits
StandardProprietary (Twitter)RFC 9562
EpochCustom (2010 or similar)Unix epoch (1970-01-01)
Sequence4096/ms per machineProbabilistic (74 random bits)
Collision risk0 if machine IDs unique~2.6×10⁻¹¹ per trillion IDs
DB column typeBIGINTUUID (16 bytes)
Human-readableAs integer or binaryStandard UUID string

When to use Snowflake IDs vs UUID v7

Prefer Snowflake ID when:

Prefer UUID v7 when:

Further reading

Frequently asked questions

What is a Snowflake ID?

A Snowflake ID is a 64-bit integer composed of a 41-bit millisecond timestamp (from a custom epoch), a 10-bit machine/datacenter ID, and a 12-bit sequence number. It was created by Twitter and later adopted by Discord, Instagram, and other high-traffic services. Snowflake IDs sort chronologically as integers and fit in a database BIGINT column. See ULID for another Snowflake alternative.

What are the limitations of Snowflake IDs compared to UUID v7?

Snowflake IDs require each generator instance to have a unique machine ID — typically assigned from a central registry or ZooKeeper. Without coordination, two generators with the same machine ID can produce collisions within the same millisecond sequence. UUID v7 avoids this with 74 random bits: no machine ID registry, no coordination, and safe to generate in serverless functions, Lambda, or Cloudflare Workers. See What is a UUID.

Should I use Snowflake IDs or UUID v7 for new projects?

For new projects, UUID v7 is generally preferred: it is an RFC standard (RFC 9562), requires no coordination, uses a standard format supported by most databases and ORMs, and fits in a UUID column (16 bytes). Snowflake IDs are better if you need a BIGINT primary key for SQL Server or MySQL compatibility or require a 64-bit ID for legacy interop. See UUID v4 vs v7.