How do I create a GUID / UUID?
@lebyy▲ 0 net votes
Problem: How do I create GUIDs (globally-unique identifiers) in JavaScript? The GUID / UUID should be at least 32 characters and should stay in the ASCII range to avoid trouble when passing them around. I'm not sure what routines are available on all browsers, how… Fix (from the top answer): [Edited 2023-03-05 to reflect latest best-practices for producing RFC4122-compliant UUIDs] crypto.randomUUID() is now standard on all modern browsers and JS runtimes. However, because new browser APIs are restricted to secure contexts , this method is only available to pages served locally ( localhost or 127.0.0.1 )…