[{"data":1,"prerenderedAt":564},["ShallowReactive",2],{"guide-uuid-versions-explained":3},{"id":4,"title":5,"body":6,"date":554,"description":555,"extension":556,"meta":557,"navigation":558,"path":559,"readingTime":560,"seo":561,"stem":562,"__hash__":563},"guides\u002Fguides\u002Fuuid-versions-explained.md","UUID Versions Explained: v1, v3, v4, v5, and v7",{"type":7,"value":8,"toc":542},"minimark",[9,14,18,29,36,40,43,49,59,64,75,78,82,85,129,133,141,145,156,159,163,166,187,191,202,207,215,218,222,225,248,252,260,264,272,275,279,282,288,292,303,307,315,318,322,471,475,501,505,526,530,538],[10,11,13],"h2",{"id":12},"what-is-a-uuid","What Is a UUID?",[15,16,17],"p",{},"A UUID (Universally Unique Identifier) is a 128-bit identifier that is unique across space and time without requiring a central coordinator. UUIDs appear as 36-character strings with hyphens:",[19,20,25],"pre",{"className":21,"code":23,"language":24},[22],"language-text","550e8400-e29b-41d4-a716-446655440000\n","text",[26,27,23],"code",{"__ignoreMap":28},"",[15,30,31,32,35],{},"The format breaks down as ",[26,33,34],{},"8-4-4-4-12"," hexadecimal digits. The third group's first digit indicates the UUID version. RFC 4122 defines versions 1, 3, 4, and 5, while RFC 9562 adds version 7.",[10,37,39],{"id":38},"uuid-v1-time-and-node-based","UUID v1: Time and Node Based",[15,41,42],{},"UUID v1 combines a 60-bit timestamp (100-nanosecond intervals since October 15, 1582) with the MAC address of the generating machine.",[15,44,45],{},[46,47,48],"strong",{},"Strengths:",[50,51,52,56],"ul",{},[53,54,55],"li",{},"Sortable by generation time",[53,57,58],{},"No collision risk across machines with different MAC addresses",[15,60,61],{},[46,62,63],{},"Weaknesses:",[50,65,66,69,72],{},[53,67,68],{},"Exposes the machine's MAC address — a privacy concern",[53,70,71],{},"Predictable: knowing the timestamp and node reveals the UUID",[53,73,74],{},"Clock drift on a single machine can cause duplicates",[15,76,77],{},"Use v1 when you need traceability to a specific machine and timestamp, such as audit logging in controlled environments.",[10,79,81],{"id":80},"uuid-v3-md5-namespace-hash","UUID v3: MD5 Namespace Hash",[15,83,84],{},"UUID v3 generates identifiers by hashing a namespace UUID and a name using MD5. The same namespace and name always produce the same UUID.",[19,86,90],{"className":87,"code":88,"language":89,"meta":28,"style":28},"language-javascript shiki shiki-themes github-light github-dark","\u002F\u002F Same inputs always yield the same v3 UUID\nuuidv3('example.com', namespace.DNS) \u002F\u002F → 9073926b-929f-31c2-abc9-fad77ae3e8eb\n","javascript",[26,91,92,101],{"__ignoreMap":28},[93,94,97],"span",{"class":95,"line":96},"line",1,[93,98,100],{"class":99},"sJ8bj","\u002F\u002F Same inputs always yield the same v3 UUID\n",[93,102,104,108,112,116,119,123,126],{"class":95,"line":103},2,[93,105,107],{"class":106},"sScJk","uuidv3",[93,109,111],{"class":110},"sVt8B","(",[93,113,115],{"class":114},"sZZnC","'example.com'",[93,117,118],{"class":110},", namespace.",[93,120,122],{"class":121},"sj4cs","DNS",[93,124,125],{"class":110},") ",[93,127,128],{"class":99},"\u002F\u002F → 9073926b-929f-31c2-abc9-fad77ae3e8eb\n",[15,130,131],{},[46,132,48],{},[50,134,135,138],{},[53,136,137],{},"Deterministic: reproduce the same UUID from the same inputs",[53,139,140],{},"No need to store the mapping — recompute on the fly",[15,142,143],{},[46,144,63],{},[50,146,147,150,153],{},[53,148,149],{},"MD5 is cryptographically broken",[53,151,152],{},"Collision risk if two different names hash to the same value",[53,154,155],{},"Not sortable by time",[15,157,158],{},"Use v3 for consistent naming in systems where you recreate identifiers from known inputs, like generating stable URIs from DNS names.",[10,160,162],{"id":161},"uuid-v4-random","UUID v4: Random",[15,164,165],{},"UUID v4 uses random or pseudo-random bits for all 122 variable bits. This is the most widely used version.",[19,167,169],{"className":87,"code":168,"language":89,"meta":28,"style":28},"\u002F\u002F Each call produces a different random UUID\nuuidv4() \u002F\u002F → f47ac10b-58cc-4372-a567-0e02b2c3d479\n",[26,170,171,176],{"__ignoreMap":28},[93,172,173],{"class":95,"line":96},[93,174,175],{"class":99},"\u002F\u002F Each call produces a different random UUID\n",[93,177,178,181,184],{"class":95,"line":103},[93,179,180],{"class":106},"uuidv4",[93,182,183],{"class":110},"() ",[93,185,186],{"class":99},"\u002F\u002F → f47ac10b-58cc-4372-a567-0e02b2c3d479\n",[15,188,189],{},[46,190,48],{},[50,192,193,196,199],{},[53,194,195],{},"Minimal collision risk: probability of a duplicate among 10³⁷ UUIDs is negligible",[53,197,198],{},"No coordination needed between systems",[53,200,201],{},"Simple to generate — no clock or network dependency",[15,203,204],{},[46,205,206],{},"Weaknesses",[50,208,209,212],{},[53,210,211],{},"Not sortable — random order harms database index performance",[53,213,214],{},"No embedded metadata",[15,216,217],{},"Use v4 as the default choice when you need simple, collision-free identifiers without sortability requirements.",[10,219,221],{"id":220},"uuid-v5-sha-1-namespace-hash","UUID v5: SHA-1 Namespace Hash",[15,223,224],{},"UUID v5 works like v3 but uses SHA-1 instead of MD5. It is the recommended replacement for v3.",[19,226,228],{"className":87,"code":227,"language":89,"meta":28,"style":28},"uuidv5('example.com', namespace.DNS) \u002F\u002F → c4d7a8a5-71ad-5b36-9c8e-4e6a5d2f1b03\n",[26,229,230],{"__ignoreMap":28},[93,231,232,235,237,239,241,243,245],{"class":95,"line":96},[93,233,234],{"class":106},"uuidv5",[93,236,111],{"class":110},[93,238,115],{"class":114},[93,240,118],{"class":110},[93,242,122],{"class":121},[93,244,125],{"class":110},[93,246,247],{"class":99},"\u002F\u002F → c4d7a8a5-71ad-5b36-9c8e-4e6a5d2f1b03\n",[15,249,250],{},[46,251,48],{},[50,253,254,257],{},[53,255,256],{},"Same determinism as v3",[53,258,259],{},"SHA-1 provides stronger collision resistance than MD5",[15,261,262],{},[46,263,63],{},[50,265,266,269],{},[53,267,268],{},"SHA-1 is deprecated for cryptographic purposes (though acceptable for UUID generation)",[53,270,271],{},"Still not time-sortable",[15,273,274],{},"Use v5 instead of v3 in all new systems that need deterministic UUIDs.",[10,276,278],{"id":277},"uuid-v7-time-ordered-modern-standard","UUID v7: Time-Ordered Modern Standard",[15,280,281],{},"UUID v7 combines a 48-bit Unix millisecond timestamp with random bits. It combines the sortability of v1 with the simplicity of v4.",[19,283,286],{"className":284,"code":285,"language":24},[22],"| 48-bit timestamp (ms) | 4-bit ver | 12-bit rand | 2-bit var | 62-bit rand |\n",[26,287,285],{"__ignoreMap":28},[15,289,290],{},[46,291,48],{},[50,293,294,297,300],{},[53,295,296],{},"Time-sortable: excellent for database indexing",[53,298,299],{},"No privacy leak — no MAC address embedded",[53,301,302],{},"Drop-in replacement for v4 in most systems",[15,304,305],{},[46,306,63],{},[50,308,309,312],{},[53,310,311],{},"Newer standard — not yet supported everywhere",[53,313,314],{},"Millisecond precision means sub-millisecond ordering relies on random bits only",[15,316,317],{},"Use v7 for new projects that need sortability, especially in database-heavy applications.",[10,319,321],{"id":320},"uuid-version-comparison","UUID Version Comparison",[323,324,325,350],"table",{},[326,327,328],"thead",{},[329,330,331,335,338,341,344,347],"tr",{},[332,333,334],"th",{},"Feature",[332,336,337],{},"v1",[332,339,340],{},"v3",[332,342,343],{},"v4",[332,345,346],{},"v5",[332,348,349],{},"v7",[351,352,353,376,395,412,429,449],"tbody",{},[329,354,355,361,364,367,370,373],{},[356,357,358],"td",{},[46,359,360],{},"Generation",[356,362,363],{},"Timestamp + MAC",[356,365,366],{},"MD5 hash",[356,368,369],{},"Random",[356,371,372],{},"SHA-1 hash",[356,374,375],{},"Timestamp + Random",[329,377,378,383,386,389,391,393],{},[356,379,380],{},[46,381,382],{},"Sortable",[356,384,385],{},"Yes",[356,387,388],{},"No",[356,390,388],{},[356,392,388],{},[356,394,385],{},[329,396,397,402,404,406,408,410],{},[356,398,399],{},[46,400,401],{},"Deterministic",[356,403,388],{},[356,405,385],{},[356,407,388],{},[356,409,385],{},[356,411,388],{},[329,413,414,419,421,423,425,427],{},[356,415,416],{},[46,417,418],{},"Privacy-safe",[356,420,388],{},[356,422,385],{},[356,424,385],{},[356,426,385],{},[356,428,385],{},[329,430,431,436,439,442,445,447],{},[356,432,433],{},[46,434,435],{},"Collision risk",[356,437,438],{},"Very low",[356,440,441],{},"Possible",[356,443,444],{},"Negligible",[356,446,438],{},[356,448,444],{},[329,450,451,456,459,462,465,468],{},[356,452,453],{},[46,454,455],{},"Best for",[356,457,458],{},"Audit trails",[356,460,461],{},"Legacy deterministic IDs",[356,463,464],{},"General purpose",[356,466,467],{},"Deterministic IDs",[356,469,470],{},"Modern databases",[10,472,474],{"id":473},"which-version-should-you-use","Which Version Should You Use?",[50,476,477,483,489,495],{},[53,478,479,482],{},[46,480,481],{},"Default choice?"," UUID v4 — battle-tested, zero coordination, widely supported",[53,484,485,488],{},[46,486,487],{},"Database performance matters?"," UUID v7 — time-ordered, index-friendly",[53,490,491,494],{},[46,492,493],{},"Need reproducible IDs?"," UUID v5 — deterministic from namespace + name",[53,496,497,500],{},[46,498,499],{},"Legacy system requiring deterministic IDs?"," UUID v3 — same as v5 but with MD5",[10,502,504],{"id":503},"related-guides","Related Guides",[50,506,507,514,520],{},[53,508,509],{},[510,511,513],"a",{"href":512},"\u002Fguides\u002Funique-identifiers-guide","Unique Identifiers Guide",[53,515,516],{},[510,517,519],{"href":518},"\u002Fguides\u002Fuuid-vs-ulid","UUID vs ULID",[53,521,522],{},[510,523,525],{"href":524},"\u002Fguides\u002Fstrong-password-guide","Strong Passwords Guide",[10,527,529],{"id":528},"try-it-yourself","Try It Yourself",[15,531,532,533,537],{},"Generate UUIDs in any version instantly with our free ",[510,534,536],{"href":535},"\u002Ftools\u002Fuuid-generator","UUID Generator",". Compare v4 randomness and v7 sortability side by side — no signup required.",[539,540,541],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":28,"searchDepth":103,"depth":103,"links":543},[544,545,546,547,548,549,550,551,552,553],{"id":12,"depth":103,"text":13},{"id":38,"depth":103,"text":39},{"id":80,"depth":103,"text":81},{"id":161,"depth":103,"text":162},{"id":220,"depth":103,"text":221},{"id":277,"depth":103,"text":278},{"id":320,"depth":103,"text":321},{"id":473,"depth":103,"text":474},{"id":503,"depth":103,"text":504},{"id":528,"depth":103,"text":529},"2026-05-27","Understand different UUID versions and their use cases. Learn when to use UUID v4 vs v7 and how each version generates unique identifiers.","md",{"immutable":558},true,"\u002Fguides\u002Fuuid-versions-explained",6,{"title":5,"description":555},"guides\u002Fuuid-versions-explained","1Yc8yCKeI9pkIwPw_pAEARxPXsQWVXk_lwcWu8btl9Q",1780401325765]