UUID, ULID and NanoID: Which Unique ID Should You Use?
Developer · October 7, 2026 · 1 min read
Almost every app needs unique identifiers for users, orders and records. Using a random ID instead of a counter means you can create IDs anywhere, without asking a central database, and nobody can guess the next one.
UUID v4
The classic. It is 128 bits, of which 122 are random, written as 36 characters like 3f2b8c1e-7a4d-4f6b-9d2e-1c5a8b7e0f34. The chance of two matching is so small it can be ignored. It works everywhere, and nearly every language and database understands it.
UUID v7
A newer version that starts with a 48-bit timestamp in milliseconds, followed by random bits. New IDs sort after older ones. That helps databases, because inserts land near the end of an index instead of at random places, which is usually faster and keeps the index compact.
ULID
A 26-character ID that also starts with a timestamp, written in Crockford Base32, which skips the letters I, L, O and U to avoid confusion. It is shorter than a UUID, easy to read aloud and sorts by time as plain text.
NanoID
A short random string, 21 characters by default, made from letters, numbers, _ and -. It is good for URLs and short links. You can choose the length and the characters, but a shorter ID has fewer possible values, so collisions become more likely.
How to choose
- Need the safest, most widely supported choice? Use UUID v4.
- Storing rows in a database and want time order? Use UUID v7 or ULID.
- Need a short, friendly string for a URL? Use NanoID.
- Never use any of these as a secret. IDs identify things, but they aren't passwords or access tokens by themselves.
Try each type in the UUID Generator and the ULID & NanoID Generator. If you need a fixed fingerprint of some data instead of a random ID, that is what the Hash Generator is for.