UUID Generator

Generate UUID v4 and time-ordered v7 in bulk.

About this tool

Generate random UUID v4 or time-ordered UUID v7 identifiers, one or a hundred at a time, using the browser’s cryptographically secure random generator.

How to use it

  1. Choose v4 for fully random IDs or v7 for IDs that sort by creation time.
  2. Set how many you need, up to 100.
  3. Choose uppercase or no hyphens if your system expects them.
  4. Copy one or all of them.

Questions

Should I use UUID v4 or v7?
v7 starts with a timestamp, so new IDs sort after older ones. That keeps database indexes compact and fast, which makes v7 a good default for primary keys. Use v4 when the creation time shouldn’t be visible.
Can two UUIDs collide?
In practice, no. A v4 UUID has 122 random bits; you would need to generate billions per second for many years before a collision became likely.
Are these UUIDs secure to use as tokens?
They are generated with the browser’s cryptographically secure random generator, but a UUID is an identifier, not a secret. For session tokens or API keys, use a longer random value.
How do I generate a UUID in JavaScript, Python or the shell?
In browsers and Node.js, crypto.randomUUID() returns a v4. In Python, use uuid.uuid4(), or uuid.uuid7() from Python 3.14. On macOS and Linux, uuidgen prints a random UUID; macOS prints it in uppercase. For a quick batch of v7 IDs, or up to 100 at once, use this page.
Do UUID v7 keys sort correctly in SQL Server?
Not by default. SQL Server’s uniqueidentifier type compares the last six bytes first, so time-ordered UUIDs don’t land at the end of a clustered index. NEWSEQUENTIALID() is SQL Server’s own sequential option. PostgreSQL and MySQL with BINARY(16) compare bytes from the start, so v7 sorts correctly there.
What is the nil UUID?
It is the all-zero value 00000000-0000-0000-0000-000000000000, used as a placeholder for “no ID”. RFC 9562 also defines a Max UUID with every digit set to f. Neither is random, so never use them as real identifiers, and reject them where a real ID is expected.

What is a UUID and how is it structured?

A UUID is a 128-bit identifier written as 32 hexadecimal digits in five groups: 8-4-4-4-12. The first digit of the third group is the version, so a v4 UUID always has a 4 there and a v7 has a 7. The first digit of the fourth group is 8, 9, a or b, marking the standard variant. A GUID is Microsoft’s name for the same format.

In a UUID v7, the first 48 bits are the Unix time in milliseconds, so the first 12 hex digits tell you when it was created; convert them to decimal with the Number Base Converter and paste the result into the Unix Timestamp Converter. The remaining 74 bits are random. IDs made in the same millisecond are not ordered among themselves here, but IDs from different milliseconds always sort by time.

How to store UUIDs in a database

Use a native type when there is one. PostgreSQL has uuid, which takes 16 bytes and accepts both cases, with or without hyphens. gen_random_uuid() creates a v4 inside the database, and PostgreSQL 18 adds uuidv7(). In MySQL, store BINARY(16) with UUID_TO_BIN() and BIN_TO_UUID() rather than CHAR(36), which takes more than twice the space and makes every index larger.

The standard text form is lowercase with hyphens, and RFC 9562 says readers should accept uppercase too. Some systems expect uppercase, or 32 digits without hyphens, so both options are available here; the value stays the same either way. When comparing UUIDs as strings in code or in logs, normalise the case first, or a GUID from a Windows tool won’t match the same ID in lowercase.

UUID vs auto-increment ID

Auto-increment integers are small, fast and easy to read, but the database assigns them, so you only know the ID after the insert. They also reveal how many rows you have and let anyone guess neighbouring records in a URL. UUIDs can be generated anywhere, in the browser, on several servers or offline, and merged later without conflicts.

The trade-off is size: 16 bytes instead of 4 or 8, in every index and foreign key. UUID v7 removes the main performance problem of random keys because new values land at the end of the index. ULID is a similar idea, a timestamp followed by random bits in a 26-character text form, but UUID v7 has a standard format and native column types in many databases.

Something not working, or a result looks wrong? Report a problem with this tool