Developer and Text Tools

UUID v7 vs ULID vs Snowflake: Choosing a Sortable ID

Compare UUID v4 and v7, ULID, KSUID, Snowflake, CUID2 and NanoID: size, sorting, database performance and privacy, and decode the time hidden in an id.

Saizul Amin
Saizul Amin30 Oct 2026 · 3 min read
UUID v7 vs ULID vs Snowflake: Choosing a Sortable ID

UUID v7 vs ULID vs Snowflake: Choosing a Sortable ID

Every record, request and file needs an identifier, and the old choice between an auto-increment integer and a random UUID is no longer the only one. Time-ordered identifiers combine the best of both: they can be created anywhere without coordination, like a UUID, and they sort by creation time, like a counter. The free Sortable ID Generator and Decoder creates all the popular formats and decodes the timestamp inside existing ids.

Why random UUIDs hurt databases

A UUID version 4 is 122 random bits. That makes collisions practically impossible, but it also means each new row lands at a random place in the primary key index. On large tables in MySQL, PostgreSQL or SQL Server this causes page splits, poor cache use and slower inserts. Sequential integers avoid that, but they need a central counter and reveal how many records you have.

The time-ordered options

  • UUID v7 (RFC 9562, published in 2024) starts with a 48-bit Unix timestamp in milliseconds, followed by random bits. It fits any UUID column and sorts by time. For most new systems it is the right default.
  • ULID has the same 48-bit time and 80 random bits, written as 26 Crockford Base32 characters. It is case-insensitive, URL-safe and sorts correctly as plain text.
  • KSUID uses a 32-bit seconds timestamp with its own epoch in 2014 plus 128 random bits, encoded as 27 Base62 characters.
  • Snowflake ids, invented at Twitter and used by Discord and many others, pack a millisecond timestamp, a machine id and a sequence number into a 64-bit integer that fits a BIGINT.
  • MongoDB ObjectIds begin with a seconds timestamp followed by random and counter bytes.

Random-only options

CUID2 and NanoID are short random strings designed for URLs and client-side ids. CUID2 hashes time, a counter and randomness with SHA-3, so nothing can be read back from it. NanoID is simply random symbols from a URL-safe alphabet. Use them when an id must not reveal when it was created.

Hashids is different again: it turns integers you already have into short strings such as o2fXhV and back. It hides sequential ids in URLs, but anyone who learns your salt can decode them, so it is not encryption.

Decoding ids you already have

Time-ordered ids are useful in debugging because the creation time is inside them. Paste an id from a log into the decoder and it recognises the format and shows the timestamp. For UUIDs it reports the version and variant, and for versions 1 and 6 the clock sequence and node. For Snowflakes it splits out worker, process and sequence numbers.

Snowflake times need the right epoch. Discord counts from the first second of 2015, while X (Twitter) counts from November 2010. A Discord id decoded with the wrong epoch gives a date years off.

The privacy trade-off

Anyone who sees a time-ordered id can tell when the record was made, and by comparing two ids, roughly how busy your system is. For internal keys this rarely matters. For public URLs such as order or invoice links, consider a random id or a separate public token.

Generating in bulk

The generator makes up to 10,000 ids per click using the Web Crypto random generator. UUID v7 values created in the same millisecond are kept in order by incrementing a counter in the random field, as RFC 9562 allows. Snowflake sequences increment within the batch, and you can set the worker and process numbers.

Step by step

  1. Choose Generate or Decode.
  2. Pick a format and set the count and options.
  3. Copy the list or download it as a text file.
  4. To decode, paste ids one per line and choose the Snowflake epoch if needed.
  5. Download the decoded table as CSV for your notes.

Privacy

Ids are generated and decoded in your browser, so internal identifiers from logs and databases are never sent to a server.

Completely freeNo cost, no sign-up
Files stay privateEverything runs in your browser
Easy in your languageAvailable in many languages