UUID vs ULID — Which to Use?

UUID is the most common unique identifier format, but ULID has been gaining ground. What are the real differences, which is better for databases, and when should you use each?

Free Online UUID Generator

Generate v4 UUIDs in bulk. Copy single or multiple with one click. Runs in your browser.

Open UUID Generator →

What is a UUID?

A UUID (Universally Unique Identifier) is a 128-bit identifier standardised in RFC 4122. The most common version, UUID v4, is randomly generated — making collisions astronomically unlikely.

UUID v4 example
550e8400-e29b-41d4-a716-446655440000

A UUID has 32 hex characters split into 5 groups by hyphens. The format is: 8-4-4-4-12.

What is a ULID?

A ULID (Universally Unique Lexicographically Sortable Identifier) is also 128 bits, but combines a 48-bit millisecond timestamp with 80 bits of randomness.

ULID example
01ARZ3NDEKTSV4RRFFQ69G5FAV

ULIDs use Crockford's Base32 encoding — 26 characters, uppercase letters and digits, no hyphens. The first 10 characters encode the timestamp, making ULIDs sortable by creation time.

UUID vs ULID — key differences

FeatureUUID v4ULID
Length36 chars (with hyphens)26 chars
Sortable by time?NoYes
Contains timestamp?NoYes (ms precision)
URL safe?YesYes
Case sensitive?Lowercase conventionCase insensitive
Standardised?RFC 4122Community spec
DB index performanceRandom — poor for sequential insertsSorted — better for indexes
Language supportUniversally supportedLibrary required

Database performance — the real difference

This is where ULIDs have a significant advantage. Database indexes (especially B-tree indexes like PostgreSQL's default) work best with sequential values. Random UUIDs cause index fragmentation — each new insert lands in a random position in the index, causing frequent page splits and increased I/O.

ULIDs, being time-sortable, are mostly inserted at the end of the index (since new records have larger timestamps). This leads to better write performance at scale — similar to auto-increment integers but without requiring a centralised counter.

Note: UUID v7 (a newer version of the UUID standard) addresses this by embedding a timestamp like ULID does. If your database library supports UUID v7, it's a good alternative that maintains the UUID format.

When to use UUID

When to use ULID

Generate UUIDs online

Use the tinybench.dev UUID generator to generate v4 UUIDs in bulk — generate 1 to 100 at once, copy individually or all at once. Everything runs in your browser.

Frequently asked questions

Can two UUIDs ever be the same?
Theoretically yes, but practically never. A UUID v4 has 122 bits of randomness. The probability of generating a duplicate in 1 billion UUIDs is about 1 in 10^18 — less likely than being struck by lightning twice.
Should I store UUIDs as strings or binary in the database?
Binary (16 bytes) is more efficient than storing as a string (36 bytes for UUID with hyphens). PostgreSQL has a native UUID type. MySQL users often use BINARY(16) for better performance than VARCHAR(36).
What is UUID v7?
UUID v7 is a newer version (RFC 9562) that embeds a millisecond timestamp in the first 48 bits — similar to ULID but in the familiar UUID format. It provides the sortability benefits of ULID while maintaining full UUID compatibility. Native support is growing in databases and languages.

Try it now — free & private

Runs entirely in your browser. No sign-up, no uploads, no tracking.

Open UUID Generator →

Related tools on tinybench.dev