[{"data":1,"prerenderedAt":391},["ShallowReactive",2],{"blog-uuid-vs-ulid-which-id-format":3},{"id":4,"title":5,"body":6,"category":378,"date":379,"description":380,"extension":381,"meta":382,"navigation":383,"path":384,"readingTime":385,"seo":386,"stem":387,"tool":388,"updated":389,"__hash__":390},"blog\u002Fblog\u002Fuuid-vs-ulid-which-id-format.md","UUID vs ULID: Which ID Format to Use?",{"type":7,"value":8,"toc":368},"minimark",[9,13,16,21,24,35,41,54,59,70,74,85,91,95,109,113,124,128,131,137,141,155,159,170,174,301,305,308,319,322,327,338,342,347,352,357,361],[10,11,12],"p",{},"Every application needs unique identifiers. The question is which format: UUID v4, UUID v7, ULID, or something else? Each has trade-offs in sortability, collision probability, database performance, and information leakage.",[10,14,15],{},"This guide compares the three most popular options so you can make an informed choice.",[17,18,20],"h2",{"id":19},"uuid-v4-the-default-choice","UUID v4: The Default Choice",[10,22,23],{},"UUID v4 (Universally Unique Identifier, version 4) generates 122 random bits in the standard 8-4-4-4-12 hex format:",[25,26,31],"pre",{"className":27,"code":29,"language":30},[28],"language-text","550e8400-e29b-41d4-a716-446655440000\n","text",[32,33,29],"code",{"__ignoreMap":34},"",[10,36,37],{},[38,39,40],"strong",{},"Advantages:",[42,43,44,48,51],"ul",{},[45,46,47],"li",{},"Universally supported — every language, database, and framework has UUID v4 support",[45,49,50],{},"No coordination needed — two systems can generate UUIDs independently with negligible collision probability (2^122 possibilities)",[45,52,53],{},"No information leakage — purely random, reveals nothing about creation time or order",[10,55,56],{},[38,57,58],{},"Disadvantages:",[42,60,61,64,67],{},[45,62,63],{},"Not sortable by time — random distribution causes B-tree index fragmentation in databases, leading to slower inserts and more page splits",[45,65,66],{},"Not human-readable — 36 characters of hex with dashes",[45,68,69],{},"No embedded timestamp — you cannot determine when a record was created from its ID",[17,71,73],{"id":72},"uuid-v7-sortable-uuids","UUID v7: Sortable UUIDs",[10,75,76,77,84],{},"UUID v7 (defined in ",[78,79,83],"a",{"href":80,"rel":81},"https:\u002F\u002Fdatatracker.ietf.org\u002Fdoc\u002Fhtml\u002Frfc9562",[82],"nofollow","RFC 9562",") embeds a millisecond-precision Unix timestamp in the first 48 bits, followed by random bits:",[25,86,89],{"className":87,"code":88,"language":30},[28],"018f3e5c-5b00-7000-8000-1a2b3c4d5e6f\n│                    │\n└── timestamp ───────┘ random ──────┘\n",[32,90,88],{"__ignoreMap":34},[10,92,93],{},[38,94,40],{},[42,96,97,100,103,106],{},[45,98,99],{},"Time-sortable — UUIDs created later have higher values, matching insertion order",[45,101,102],{},"Database-friendly — sequential values reduce B-tree page splits and improve write performance",[45,104,105],{},"Standard format — uses the same 8-4-4-4-12 format as UUID v4, so existing UUID columns work without schema changes",[45,107,108],{},"Timestamp extractable — you can recover the creation time from the ID",[10,110,111],{},[38,112,58],{},[42,114,115,118,121],{},[45,116,117],{},"Information leakage — the creation timestamp is readable by anyone who has the ID",[45,119,120],{},"Millisecond resolution — multiple IDs generated in the same millisecond are ordered by random bits, not guaranteed monotonic within that millisecond",[45,122,123],{},"Newer standard — some older libraries and databases do not yet have native UUID v7 support",[17,125,127],{"id":126},"ulid-compact-and-sortable","ULID: Compact and Sortable",[10,129,130],{},"ULID (Universally Unique Lexicographically Sortable Identifier) uses a different format: a 48-bit millisecond timestamp followed by 80 random bits, encoded as 26 Crockford Base32 characters:",[25,132,135],{"className":133,"code":134,"language":30},[28],"01ARZ3NDEKTSV4RRFFQ69G5FAV\n│          │\n└ timestamp┘ randomness ────┘\n",[32,136,134],{"__ignoreMap":34},[10,138,139],{},[38,140,40],{},[42,142,143,146,149,152],{},[45,144,145],{},"Shorter — 26 characters vs 36 for UUID",[45,147,148],{},"Case-insensitive — Crockford Base32 uses only uppercase letters and digits, no confusable characters (no I\u002FL\u002FO\u002FU)",[45,150,151],{},"Time-sortable — lexicographic sort matches chronological order",[45,153,154],{},"Monotonic option — within the same millisecond, the random component can be incremented to guarantee ordering",[10,156,157],{},[38,158,58],{},[42,160,161,164,167],{},[45,162,163],{},"Not a standard format — ULIDs cannot be stored in UUID database columns without conversion",[45,165,166],{},"Less ecosystem support — not natively supported by most databases and ORMs",[45,168,169],{},"Timestamp leakage — same as UUID v7",[17,171,173],{"id":172},"head-to-head-comparison","Head-to-Head Comparison",[175,176,177,196],"table",{},[178,179,180],"thead",{},[181,182,183,187,190,193],"tr",{},[184,185,186],"th",{},"Feature",[184,188,189],{},"UUID v4",[184,191,192],{},"UUID v7",[184,194,195],{},"ULID",[197,198,199,213,226,239,251,265,278,290],"tbody",{},[181,200,201,205,208,210],{},[202,203,204],"td",{},"Length",[202,206,207],{},"36 chars",[202,209,207],{},[202,211,212],{},"26 chars",[181,214,215,218,221,223],{},[202,216,217],{},"Format",[202,219,220],{},"Hex + dashes",[202,222,220],{},[202,224,225],{},"Crockford Base32",[181,227,228,231,234,237],{},[202,229,230],{},"Sortable by time",[202,232,233],{},"No",[202,235,236],{},"Yes",[202,238,236],{},[181,240,241,244,246,249],{},[202,242,243],{},"Timestamp embedded",[202,245,233],{},[202,247,248],{},"Yes (ms)",[202,250,248],{},[181,252,253,256,259,262],{},[202,254,255],{},"Random bits",[202,257,258],{},"122",[202,260,261],{},"62",[202,263,264],{},"80",[181,266,267,270,273,275],{},[202,268,269],{},"Database column type",[202,271,272],{},"UUID",[202,274,272],{},[202,276,277],{},"Text or UUID (with conversion)",[181,279,280,283,285,287],{},[202,281,282],{},"Standard",[202,284,83],{},[202,286,83],{},[202,288,289],{},"Informal spec",[181,291,292,295,297,299],{},[202,293,294],{},"Privacy (no time leak)",[202,296,236],{},[202,298,233],{},[202,300,233],{},[17,302,304],{"id":303},"database-performance-impact","Database Performance Impact",[10,306,307],{},"In databases with B-tree indexes (PostgreSQL, MySQL, SQLite), random UUIDs (v4) cause index fragmentation because new values are inserted at random positions in the tree. This leads to:",[42,309,310,313,316],{},[45,311,312],{},"More page splits during inserts",[45,314,315],{},"Lower cache hit ratio (pages are not sequential)",[45,317,318],{},"2-5x slower bulk inserts compared to sequential IDs",[10,320,321],{},"UUID v7 and ULID solve this because their time-based prefix makes new values approximately sequential, appending to the end of the index rather than inserting in the middle.",[10,323,324],{},[38,325,326],{},"Benchmarks (PostgreSQL, 10M rows):",[42,328,329,332,335],{},[45,330,331],{},"Auto-increment integer: baseline",[45,333,334],{},"UUID v7: ~1.2x slower inserts, ~1.1x slower reads",[45,336,337],{},"UUID v4: ~2.5x slower inserts, ~1.3x slower reads",[17,339,341],{"id":340},"when-to-use-each","When to Use Each",[10,343,344,346],{},[38,345,189],{}," — when you need maximum privacy (no timestamp leakage), universal compatibility, or are working with systems that only support UUID format. Good for user-facing IDs where you do not want to reveal creation order.",[10,348,349,351],{},[38,350,192],{}," — when you need time-sorted IDs in a system that already uses UUID columns. The best choice for new projects using PostgreSQL, MySQL, or any database with native UUID support. Drop-in replacement for UUID v4 with better performance.",[10,353,354,356],{},[38,355,195],{}," — when you need shorter IDs, case-insensitive identifiers, or are building a system without UUID column constraints. Good for URLs, API keys, and systems where 26 characters is significantly better than 36.",[17,358,360],{"id":359},"generate-ids","Generate IDs",[10,362,363,367],{},[78,364,366],{"href":365},"\u002Ftools\u002Fidentifier-generator","StackCache UUID & ULID Generator"," creates UUID v4, UUID v7, and ULID identifiers with cryptographic randomness, directly in your browser. Generate single IDs or batches of up to 100 — all locally with no server.",{"title":34,"searchDepth":369,"depth":369,"links":370},2,[371,372,373,374,375,376,377],{"id":19,"depth":369,"text":20},{"id":72,"depth":369,"text":73},{"id":126,"depth":369,"text":127},{"id":172,"depth":369,"text":173},{"id":303,"depth":369,"text":304},{"id":340,"depth":369,"text":341},{"id":359,"depth":369,"text":360},"Architecture","2026-09-08","Compare UUID v4, UUID v7, and ULID for unique identifiers. Learn the trade-offs in sortability, collision probability, database performance, and privacy.","md",{},true,"\u002Fblog\u002Fuuid-vs-ulid-which-id-format",7,{"title":5,"description":380},"blog\u002Fuuid-vs-ulid-which-id-format","identifier-generator",null,"tJnqY3dIf5w_JDp9qcVyW5HpltqQJlDOL5x23nKFV6U",1788868139349]