UUID v4 Generator
Generate cryptographically random UUID v4 identifiers. Generate up to 100 at once and copy them all.
What a UUID Actually Is
A UUID (Universally Unique Identifier) is a 128-bit identifier formatted as 32 hex digits in five groups: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. The version number appears as the first digit of the third group (a v4 UUID always has a 4 there). The "universally unique" claim relies on the birthday paradox calculation: with v4's 122 random bits, you would need to generate approximately 2.7 × 10¹⁸ UUIDs before having a 50% chance of a single collision. In practice, UUIDs are treated as unique for all realistic purposes — billions of databases and distributed systems rely on this property daily.
UUID v4: Random Generation
UUID v4 is entirely random except for 6 fixed bits that encode the version and variant. It's the most widely supported and simplest version — generation requires only a CSPRNG (Cryptographically Secure Pseudo-Random Number Generator), which is available in every modern runtime. The downside is that v4 UUIDs are not sortable by generation time. In database primary keys, randomly distributed UUIDs cause B-tree index fragmentation because inserts happen at random positions rather than at the end of the index. For low to moderate insert rates, this is acceptable. For high-volume write systems, it can cause measurable performance degradation compared to sequential identifiers.
UUID v7: Time-Ordered IDs
UUID v7 (RFC 9562, finalised 2024) encodes a millisecond-precision Unix timestamp in the most significant bits, followed by random bits. This makes v7 UUIDs sortable by creation time while retaining uniqueness. Sorted UUIDs insert at the end of B-tree indexes, significantly reducing fragmentation and improving database write performance. v7 is now the recommended choice for new database primary key use cases. If your ORM or database library supports v7 generation, prefer it over v4 for IDs stored in indexed database columns. For non-database uses (request tracing, session tokens, file names), v4 is perfectly adequate.
Frequently Asked Questions
What is a UUID v4?
When should I use a UUID instead of an auto-increment ID?
Related Tools