A UUID is a 128-bit identifier. Choose v4 when several environments need to create test IDs independently. Consider v7 if the identifier should begin with a timestamp, and check whether the order within each millisecond meets your needs. Use a database primary key or unique constraint wherever uniqueness is required.
Compare UUID v4, v7 and v1
| Version | Main fields | When to choose it |
|---|---|---|
| v4 | 122 random bits | Independent generation when time order is unnecessary |
| v7 | 48-bit Unix millisecond prefix | Timestamp-first IDs, with same-ms and clock checks |
| v1 | Time, clock sequence and node | Legacy compatibility, with ordering and node exposure checks |
The leading 48 bits of v7 hold Unix milliseconds. Ordering within a millisecond and behavior when a clock goes backwards depend on the generator. For an audit trail that needs strict event order, store a sequence or event time separately. The Unix timestamp guide explains the millisecond and UTC relationship.
Identify the version and variant in a 36-character UUID
The text form uses 32 hex digits and four hyphens. Under the RFC 9562 layout, the first digit in the third group identifies the version. The high bits of the first digit in the fourth group identify the variant. Version and variant take six bits in v4, leaving 122 random bits.
| Location | Example | Check |
|---|---|---|
| Group widths | 8-4-4-4-12 | 32 hex digits and four hyphens |
| Third group starts with | 4 |
Version 4 |
| Fourth group starts with | a |
The RFC variant starts with 8, 9, a or b |
Generate a fresh value for each new record. The diagram shows a fixed example for checking the format. The base conversion guide maps each hex digit to four bits.
Try the worked example
Generate one v4 and inspect its format
Set the count to 1. Check for 4 at the start of group 3 and 8, 9, a or b at the start of group 4.
Estimate collisions and enforce uniqueness
With independent, uniformly random fields there are 2¹²² possibilities. When the collision probability is small, the probability of at least one collision among n generated values is approximately n(n−1) ÷ (2 × 2¹²²). For a billion values this is about 9.4×10⁻²⁰. It excludes generator defects, accidental reuse and truncation.
| Requirement | Control | Test case |
|---|---|---|
| Identify a new row | PRIMARY KEY | Reject a second row with the same key |
| Reference a parent row | FOREIGN KEY | Reject an ID with no matching parent |
| Limit access | Authorize each request | Deny access to another user’s record |
Keeping only the first eight hexadecimal digits gives at most 32 bits of possibilities. A uniform sample of 100,000 such values has about a 69% chance of a collision. Keep the full UUID for storage and matching, even when the interface shows a shortened label.
Generate, copy and save a test batch
- Enter a whole number from 1 to 1,000. The page initially shows 10 IDs.
- Generate and verify the requested count and 36-character format. The tool uses
crypto.randomUUID()where available, with a v4 fallback based oncrypto.getRandomValues(). - Copy the whole list or download
uuids.txt, with one value per line. Save the values you need before generating again. - In a test database, check rejection of duplicate primary keys and missing foreign key targets. If an insertion is retried, verify that the same request cannot create two records.
Try the worked example
Save a three-ID test batch
Set the count to 3 and verify that the clipboard and uuids.txt both contain three lines.
Use the regular expression guide to learn about format checks. Find the generator and converters in the developer tools category.
Editorial verification
Tools Hub editors checked the RFC, browser API, PostgreSQL constraints and generator workflow on November 9, 2026. The probability calculations assume independent, uniformly random values.
FAQ
Can this generator create UUID v7?
It generates v4 only. For v7, check whether your database or library supports it and how the generator orders IDs created in the same millisecond.
Can two UUID v4 values collide?
Yes. With independent uniform 122-bit random fields, one billion generated IDs give a collision probability of about 9.4×10⁻²⁰. Enforce uniqueness in storage and decide what to do on conflict.
Can a UUID serve as an authentication token?
Treat it as an identifier. Use an authentication scheme with separate authorization, expiry and revocation. Knowing an identifier must not grant access.
Are GUID and UUID strings interchangeable?
Both terms can refer to 128-bit identifiers. Check accepted casing, braces and formatting. For binary exchange, verify byte order as well.