UUID v7 is the default for database primary keys in 2026 — RFC 9562 standardised, native PostgreSQL 18 uuid type, 48-bit ms timestamp + 74 random bits. ULID uses the same timestamp but is 26 chars (vs 36), has no IETF RFC, and requires a text column. NanoID is ideal for short URL slugs but has no DB native type. Snowflake requires a node-registry coordination service. See UUID vs ULID.
Quick rule: UUID v7 for DB keys · UUID v4 for tokens and share links · ULID only if shorter string length matters specifically.
Read more: UUID v7 vs ULID 2026 · UUID v7 in distributed systems · URL-safe encoding
Generate UUID v7 or v4 · UUID Converter · UUID Decoder
Frequently asked questions
Should I use UUID v7 or ULID for sortable IDs?
In 2026, UUID v7 is the better default. It has RFC standardisation (RFC 9562), native PostgreSQL 18 support, and stores in the existing uuid column type. ULID has no RFC standard and requires custom storage. Choose ULID only if shorter 26-char strings are important for your use case.
What is the shortest way to encode a UUID in a URL?
Base64url encoding reduces a UUID from 36 characters (hyphenated string) to 22 characters with no padding. Strip the trailing == padding — the length is always 22. Alternatively, Base58 also produces 22 characters with no padding and no special URL characters. Both are fully reversible to the original 16-byte UUID. The uuid npm package includes uuidStringify and uuidParse for byte-level access.
Should I use v4 or v7?
Use v7 for database primary keys (time-sortable, index-friendly) and v4 for anything where creation order could leak information, like tokens or share links.