// generate v1, v4, v5 uuids · bulk generation · copy all · nothing leaves your browser
A UUID (Universally Unique Identifier) is a 128-bit label used to uniquely identify objects in computer systems. They're written as 32 hexadecimal digits in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. The probability of generating two identical UUIDs is astronomically small.
There are several UUID versions, each generated differently and suited for different use cases. Version 4 (v4) is the most common — it's randomly generated with 122 bits of entropy, making the probability of collision essentially zero for any practical application. Generate UUIDs for database primary keys, session IDs, file names, or any other identifier where uniqueness matters.
Version 1 (v1) combines the current timestamp with the MAC address of the generating machine. This makes v1 UUIDs sortable by generation time — useful when you need to retrieve records in insertion order without a separate timestamp column. However, the MAC address component raised privacy concerns, as it could identify the machine that generated the UUID.
UUID v7 (a newer standard) is gaining popularity because it combines a timestamp prefix with random data — giving the sortability of v1 without exposing MAC addresses. Many modern databases and frameworks are adopting v7 as the default. The format is always the same: 32 hexadecimal characters in the pattern 8-4-4-4-12.
Using UUIDs as primary keys has significant advantages in distributed systems. Auto-incrementing integer IDs require a central authority to assign the next number — in a distributed system with multiple database nodes, this creates a bottleneck. UUIDs can be generated independently on any node with essentially zero collision probability.
UUIDs also improve security — sequential integer IDs expose the total count of records and allow enumeration attacks. A UUID-based URL like /users/550e8400-e29b-41d4-a716-446655440000 reveals nothing about the user count and cannot be guessed. The trade-off is larger storage (16 bytes vs 4 bytes for an int) and slightly slower index performance on some databases.
crypto.randomUUID() API. The chance of a collision is 1 in 5.3×10³⁶ — effectively impossible in practice.