Generate version 4 UUIDs (universally unique identifiers)
A UUID (Universally Unique Identifier), also known as a GUID (Globally Unique Identifier), is a 128-bit identifier standardized by RFC 4122. UUIDs are designed to be unique across all systems without requiring a central authority to assign them. The standard representation is 32 hexadecimal digits displayed in five groups separated by hyphens in the form 8-4-4-4-12, such as 550e8400-e29b-41d4-a716-446655440000. The total number of possible v4 UUIDs is approximately 5.3 x 10^36, making accidental collisions virtually impossible.
Version 4 UUIDs, which this generator produces, are created using random or pseudo-random numbers. Of the 128 bits, 6 are fixed (4 bits for the version number "0100" and 2 bits for the variant "10"), leaving 122 bits of randomness. This generator uses the Web Crypto API's crypto.randomUUID() function when available, falling back to crypto.getRandomValues() for cryptographically secure random number generation, ensuring high-quality randomness for each UUID produced.
UUIDs are widely used in software development for database primary keys, distributed systems, session identifiers, file naming, API request tracking, and message queue identifiers. They are preferred over sequential integers in distributed systems because they can be generated independently on any node without coordination or risk of collision. Common formats include the standard hyphenated form, compact form without hyphens, and URN notation (urn:uuid:...). When choosing a UUID format, the standard hyphenated lowercase form is recommended for maximum compatibility across systems and programming languages.