v4 or v7?
- Version 4: 122 random bits. Use it when the ID should reveal nothing.
- Version 7 (RFC 9562, 2024): starts with a 48-bit Unix timestamp in milliseconds, then random bits. IDs sort by creation time, which keeps database indexes compact. RFC 9562 says implementations should use v7 rather than v1 or v6 when they need time ordering. The trade-off: anyone can read when the ID was created (the checker above shows it).
Will two UUIDs ever collide?
For v4, the chance is negligible for any realistic number of IDs, as long as the random source is good. This page uses crypto.randomUUID() / crypto.getRandomValues(), the browser's cryptographically secure generator. Don't generate UUIDs with Math.random().
Format
32 hex digits in 5 groups, 8-4-4-4-12. The first digit of the third group is the version; the first digit of the fourth group (8, 9, a or b) marks the standard variant.
Sources
- RFC 9562: Universally Unique IDentifiers (UUIDs): www.rfc-editor.org/rfc/rfc9562