UUID Generator

Generate UUID v4 identifiers locally — cryptographically random, nothing uploaded.

Generate UUID v4 and time-ordered v7 identifiers in bulk, and understand why the choice between them affects database write performance.

v4 versus v7

UUID v4 is 122 bits of cryptographic randomness. It is unguessable and completely unordered, which is fine for a primary key in a table you never sort and painful in a B-tree index: every insert lands in a random leaf page, causing page splits and cache misses at scale.

UUID v7 embeds a millisecond timestamp in the high bits followed by random data. Values generated close together sort close together, so inserts append to the end of the index the way an auto-increment integer would, while keeping 74 bits of randomness. For new schemas, v7 is usually the better default.

What a UUID is not

A UUID is an identifier, not a secret. v4 has enough entropy that guessing a specific value is infeasible, but treating an identifier as an authentication token is a design error: identifiers leak through logs, URLs, referrer headers and support tickets.

v1 is worse for privacy, because it encodes the generating machine's MAC address and a timestamp. If you see v1 values in an API response, that is leaking infrastructure detail.

Practical notes

Store UUIDs as native uuid columns or 16-byte binary where the database supports it. Storing them as 36-character text wastes space and makes comparisons slower, which is a real cost at millions of rows.

Bulk generation here produces one value per line so the output pastes cleanly into a SQL insert or a seed file.

Frequently asked questions

Can two generated UUIDs collide?
In practice no. v4 collision becomes likely only around 2^61 values. v7 adds a timestamp, so collisions require the same millisecond plus the same random bits.
Should I use UUID or an auto-increment integer?
Use an integer when the ID is internal and you control generation. Use UUID when IDs are exposed publicly, generated on clients, or merged across systems where sequences would conflict.
Are these generated locally?
Yes, using the browser's cryptographic random source. Nothing is sent anywhere.