UUID vs ULID — Which Should You Use?

Both are 128-bit unique identifiers. ULID is shorter and URL-safe; UUID is a formal RFC standard. Here's how to choose.

What is a ULID?

ULID (Universally Unique Lexicographically Sortable Identifier) is a 128-bit identifier encoding a 48-bit millisecond timestamp and 80 bits of randomness. It looks like this:

01ARZ3NDEKTSV4RRFFQ69G5FAV

That's 26 characters in Crockford Base32 (no hyphens, case-insensitive, no ambiguous characters like I/l or O/0). It was designed as a sortable, URL-safe alternative to UUID.

Side-by-Side Comparison

PropertyUUID (v4)UUID (v7)ULID
Bits128128128
String length36 chars36 chars26 chars
FormatHex with hyphensHex with hyphensCrockford Base32
URL-safe (no encoding needed)Yes (hyphens allowed)YesYes
Sortable by creation timeNoYesYes
Randomness bits1227480
Formal RFC standardRFC 4122 / RFC 9562RFC 9562No (community spec)
Native database supportPostgreSQL UUID, MySQL 8PostgreSQL UUID, MySQL 8Needs CHAR(26) or BINARY(16)
Standard library supportPython, Java, .NET, Node.jsPython 3.13+, Node uuid 10+Third-party packages only

When to Use ULID

  • You're building in a language/framework where ULID has strong library support (JavaScript/TypeScript with ulid npm)
  • The IDs appear in URLs and you want a cleaner, shorter look
  • You need sortability and your stack doesn't yet support UUID v7
  • You're already using ULID — no reason to migrate

When UUID v7 is Better Than ULID

For most new projects today, UUID v7 is the better choice over ULID because:

  • It's an IETF RFC standard (RFC 9562, 2024) — more interoperable
  • PostgreSQL, MySQL 8, and SQL Server support UUID columns natively
  • UUID v7 has similar database performance benefits to ULID
  • No format conversion needed when working with systems that expect UUIDs

Frequently Asked Questions

What is a ULID?

ULID (Universally Unique Lexicographically Sortable Identifier) is a 128-bit identifier that encodes a 48-bit millisecond timestamp and 80 bits of randomness in a 26-character Crockford Base32 string (e.g. 01ARZ3NDEKTSV4RRFFQ69G5FAV). Like UUID v7, it is time-ordered. Unlike UUID, it has no standard hyphens and is case-insensitive.

Is ULID better than UUID?

Neither is universally better. ULID is shorter in string form (26 chars vs 36) and URL-safe without encoding. UUID is a formal RFC standard with universal library support. For new projects that need sortable IDs and don't have legacy UUID constraints, UUID v7 provides the same benefits as ULID with better interoperability.

Can I store a ULID in a UUID database column?

Yes. ULID and UUID v7 both encode 128 bits — a ULID can be stored in a UUID or BINARY(16) column by converting it from Base32 to the standard UUID hex format. Some libraries (e.g. ulid-py) provide this conversion. Alternatively, store ULIDs as CHAR(26) to preserve the Base32 representation.

Related Comparisons & Tools