A thorough comparison of UUIDs (v4 and v7), ULIDs, and Sqids covering their generation models, sorting behavior, database storage trade-offs, and security implications. UUIDv4 offers opaque distributed IDs, UUIDv7 adds time-ordering while keeping UUID semantics, ULIDs provide compact lexicographically sortable 128-bit IDs, and Sqids generate reversible short public IDs from existing integers. The post includes PHP code examples using ramsey/uuid, robinvdvleuten/ulid, and the official Sqids package, plus a practical decision flow, database storage guidance (CHAR vs BINARY), and common mistakes like treating Sqids as encryption or relying on hard-to-guess IDs instead of proper authorization.

16m read timeFrom wendelladriel.com
Post cover image
Table of contents
IntroductionThe Problem We Are Actually SolvingThe Quick ComparisonUUIDs: The Standard WorkhorseUUIDv4UUIDv7ULIDs: Compact and Lexicographically SortableULID MonotonicitySqids: Generated IDs From NumbersSqids and Canonical IDsHow They Behave in DatabasesStoring UUIDs and ULIDsSecurity and PrivacyPublic IDs and Internal IDsA Practical Decision FlowA Small PHP AbstractionCommon MistakesConclusion
21.4K Impressions