UUID vs ULID vs NanoID comparison
July 1, 2026 · 14 min read
Three popular answers to "give me a unique string ID" - but they optimize for different goals. UUID is the interoperable standard with version bits. ULID adds lexicographic time ordering. NanoID trades standards for shorter URL-safe strings. For a focused ULID versus UUID discussion, see the dedicated ULID vs UUID article; this page adds NanoID to the picture.
At a glance
- Length - UUID 36 chars (canonical); ULID 26 Crockford Base32; NanoID default 21 (configurable).
- Sortable by time - UUID v7 yes; v4 no; ULID yes; NanoID no unless you embed time yourself.
- Standard - UUID (RFC 4122); ULID spec community; NanoID library convention.
- Charset - UUID hex + hyphens; ULID Base32; NanoID URL-safe ASCII subset.
UUID
Universally recognized in databases, logs, and OpenAPI schemas. v4 for random IDs; v7 when you want time-ordered inserts without a separate ULID dependency. Validate partner IDs with a UUID validator and generate test IDs with the UUID generator.
ULID
128 bits like UUID, 48-bit timestamp plus 80 bits randomness, case-insensitive encoding. Excellent for log correlation and roughly chronological indexes. Not every ORM exposes ULID natively - often stored as char(26) or binary.
NanoID
Small dependency, customizable alphabet and length, popular in frontend apps and short URLs. Not a substitute when compliance asks for RFC 4122. Collision resistance depends on length and alphabet size - use defaults from the maintained library.
How to choose
- Pick UUID v4/v7 when you need maximum ecosystem support and clear version semantics.
- Pick ULID when lexicographic time sort in a 26-char string matters and UUID v7 is not available yet.
- Pick NanoID when URL length is tight and you control both producer and consumer.
FAQ
- Is ULID a UUID?
- Both are 128-bit identifiers, but ULID uses a different string encoding and layout. They are not interchangeable without conversion rules.
- Which is shortest in URLs?
- NanoID at default 21 characters; ULID 26; UUID canonical 36.
Related: ULID vs UUID (deep dive) · NanoID vs UUID