UUID Generator
UUID Generator
A universally unique identifier (UUID) is a 128-bit label used for unique identification in computer systems. UUIDs are standardized by the International Telecommunication Union (ITU-T Rec. X.667 | ISO/IEC 9834-8) and the IETF in RFC 9562, which obsoletes RFC 4122. The primary advantage of UUIDs over sequential IDs (such as auto-increment integers) is that they can be generated independently by different systems without coordination — no central server, no synchronization, no collision.
UUIDs are ubiquitous in modern software development. They serve as database primary keys, API resource identifiers, session tokens, transaction IDs, event correlation IDs, and distributed system references. The 128-bit space (approximately 3.4 × 10³⁸ possible values) makes accidental collisions so improbable that they can be treated as negligible for practical purposes.
This tool generates two UUID versions: v4 (random, the most widely used) and v7 (time-ordered, RFC 9562's recommended replacement). Unlike online UUID generators that send data over the network, this tool runs entirely in your browser using the Web Crypto API — your data never leaves your machine.
Select a UUID version, choose how many UUIDs to generate (1 to 100), and click Generate UUIDs. The results appear instantly as a list of formatted UUID strings.
UUID v4 Generation
UUID v4 is the most common version. All 122 bits of the identifier (after version and variant bits) are randomly generated. This provides approximately 5.3 × 10³⁶ possible values.
Example 1 — Generate 3 UUIDs v4:
Clicking generate with count=3 produces output like:
550e8400-e29b-41d4-a716-446655440000
110ec58a-a0f2-4ac4-8393-c866d813b8d1
7d44c0d0-5c4f-4b7b-9a5a-3b2a1c0f8e9a
Each UUID follows the format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx, where 4 identifies v4 and y represents the variant bits (8, 9, A, or B).
UUID v7 Generation
UUID v7 encodes a Unix millisecond timestamp in the first 48 bits, followed by random bits for uniqueness within the same millisecond. This time-ordered structure provides several benefits over v4: UUIDs are monotonically increasing over time, enabling efficient B-tree index performance in databases, and they encode their creation time without needing a separate timestamp column.
Example 2 — Generate 3 UUIDs v7:
018f3a56-7b4c-7f00-8a23-4b7c3d2e1f00
018f3a56-7b4c-7f00-8a24-5c8d9e0f1a2b
018f3a56-7b4c-7f01-9b34-6e7f8a9b0c1d
The first characters (018f3a56-7b4c) encode the timestamp. Notice how the third UUID is slightly larger than the first two, reflecting the passage of milliseconds.
Edge Cases
- Count set to 1: Generates a single UUID. Useful when you need one unique identifier for a database record or session.
- Count set to 100: Generates 100 UUIDs at once. Useful for batch prepopulation or testing.
- Very large batches: The generator is capped at 100 per click to prevent browser performance issues. For larger batches, run the tool multiple times.
A UUID is represented as a 36-character string in the standard 8-4-4-4-12 hexadecimal format:
The 128 bits are divided into fields:
- Time fields (v1/v6/v7): 60 bits for timestamp encoding
- Version field: 4 bits indicating the UUID version (4 for v4, 7 for v7)
- Variant field: 2 bits indicating the UUID variant (RFC 9562 uses
10xx) - Random/node fields: Remaining bits for uniqueness
UUID v4 Structure
For v4, the 122 random bits (15.25 bytes) are generated using crypto.getRandomValues(), which provides cryptographically secure random numbers. The version nibble is set to 0100 (4), and the variant bits are set to 10.
UUID v7 Structure
For v7, the first 48 bits contain a Unix timestamp in milliseconds. The version field is set to 0111 (7). The remaining 74 bits are random, providing uniqueness for UUIDs generated within the same millisecond. This design makes UUID v7 the recommended choice for new applications per RFC 9562, as it combines the readability of time-sortable IDs with the collision resistance of random UUIDs.
UUID Version Comparison
| Version | Type | Bit Allocation | Sortable | Recommended Use |
|---|---|---|---|---|
| v4 | Random | 122 random + 6 fixed | No | General purpose, distributed systems |
| v7 | Time-ordered + random | 48 timestamp + 74 random | Yes | Database primary keys, new apps |
| v1 | Time + MAC | 60 timestamp + 48 MAC + 14 random | Yes | Legacy systems (privacy concerns) |
| v6 | Time-ordered (reorder v1) | 60 timestamp reordered | Yes | Transition from v1 |
UUID v4 vs v7 Index Performance
| Scenario | UUID v4 | UUID v7 | Improvement |
|---|---|---|---|
| B-tree insert (10M rows) | 3,200 inserts/s | 8,500 inserts/s | +166% |
| Page splits per 1M inserts | ~1,500 | ~50 | -97% |
| Index fragmentation | 35-50% | 5-10% | -80% |
| Cache hit rate (buffer pool) | 65% | 92% | +27 pp |
Common UUID Libraries by Language
| Language | Library | Versions Supported |
|---|---|---|
| JavaScript | crypto.randomUUID() | v4 (built-in) |
| TypeScript | uuid package | v1, v3, v4, v5, v7 |
| Python | uuid module | v1, v3, v4, v5, v7 |
| Java | java.util.UUID | v3, v4, v7 |
| Go | google/uuid | v1, v4, v5, v6, v7 |
| Rust | uuid crate | v1, v3, v4, v5, v6, v7 |
1. Use UUID v7 for new database schemas. PostgreSQL and MySQL both index UUID v7 efficiently because the time-ordered values insert sequentially into B-tree indexes. UUID v4 inserts cause random page splits and index fragmentation, degrading write performance by up to 60% on large tables.[pganalyze-uuid]
2. Store UUIDs as binary, not strings. A UUID stored as CHAR(36) requires 36 bytes plus overhead. Stored as BINARY(16) in MySQL or UUID type in PostgreSQL, it requires only 16 bytes. This saves space in indexes and speeds up comparisons.
3. Never use UUID v1 in production. UUID v1 includes the generating machine's MAC address, creating a privacy risk — an attacker who obtains a UUID v1 can identify the network hardware that generated it. Use v4 or v7 instead.
4. Cryptographically secure randomness matters. Always generate UUIDs using CSPRNG (cryptographically secure pseudo-random number generator) functions like crypto.getRandomValues() in JavaScript or /dev/urandom on Unix. The built-in Math.random() is not suitable for UUID generation.
5. Collisions are not impossible. While the probability of a UUID v4 collision is astronomically small, it is not zero. For systems with billions of UUIDs, consider using UUID v7's time-based uniqueness or adding a namespace prefix.
6. Validate UUIDs before use. When accepting UUIDs from user input or external systems, validate the format with a regex: /^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i. This rejects malformed input early and prevents SQL injection when UUIDs are used in queries.
UUIDs are not without trade-offs. At 128 bits (36 characters as a string), they are significantly larger than a 32-bit integer (4 bytes) or a 64-bit bigint (8 bytes). For systems with billions of rows, this extra storage in indexes and memory can impact performance. The random nature of UUID v4 also causes index fragmentation in B-tree structures, though this is mitigated by UUID v7.
Another limitation is debuggability. Unlike sequential IDs where the ID itself encodes ordering (e.g., order #1042 was created after order #1041), UUIDs in v4 convey no temporal information. UUID v7 partially addresses this by encoding the timestamp in a human-readable position.
UUIDs are also not appropriate for security-sensitive contexts like session tokens or password resets. While UUID v4 uses cryptographically secure randomness, the 122-bit space is searchable by an attacker with sufficient computational resources. For security tokens, use dedicated libraries that generate 256-bit or higher entropy random values.
Finally, UUIDs can cause issues in legacy systems designed for 32-bit or 64-bit integer keys. Database migrations from integer to UUID primary keys require careful planning, particularly for foreign key constraints and index rebuilds.
- What is the difference between UUID v4 and v7?
- UUID v4 is fully random (122 bits of entropy), while UUID v7 encodes a Unix millisecond timestamp in the first 48 bits for chronological ordering. v7 is recommended for new applications because it sorts naturally and performs better as a database primary key in B-tree indexes.
- Can two computers generate the same UUID?
- The probability is vanishingly small. UUID v4 has approximately 5.3 × 10³⁶ possible values. To reach a 50% collision probability, you would need to generate about 2.7 × 10¹⁸ UUIDs. UUID v7 reduces this further by encoding a unique timestamp, making collisions practically impossible within the same millisecond.
- How do I generate UUIDs in my programming language?
- Most languages have built-in or well-known libraries: JavaScript: `crypto.randomUUID()`, Python: `uuid.uuid4()`, Java: `java.util.UUID.randomUUID()`, Go: `uuid.New()` from `github.com/google/uuid`, Rust: `Uuid::new_v4()` from the `uuid` crate, C#: `Guid.NewGuid()`.
- What is the standard UUID format?
- A UUID is a 36-character string in the format `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` where each x is a hexadecimal digit (0-9, a-f). The 8-4-4-4-12 grouping with hyphens is standardized. The version digit (position 13) and variant digit (position 17) have specific constraints per the RFC.
- Can I convert a UUID to a shorter string?
- Yes. Base64-encoded UUIDs (without padding) are 22 characters instead of 36: `btoa(uuid.replace(/-/g, '').match(/../g).map(b => String.fromCharCode(parseInt(b, 16))).join('')).replace(/=+$/, '')` . This is common in URL-friendly identifiers. However, this representation is not a standard UUID and may cause interoperability issues.
- What is the difference between UUID and GUID?
- GUID (Globally Unique Identifier) is Microsoft's implementation of the UUID standard. The terms are often used interchangeably, but GUIDs sometimes use a different byte ordering (little-endian) for the first three components, following Windows' mixed-endian structure. For cross-platform systems, prefer standard UUID format.
- Are UUIDs case-sensitive?
- UUIDs are defined in lowercase hexadecimal by convention, but they are case-insensitive. `550e8400-e29b-41d4-a716-446655440000` and `550E8400-E29B-41D4-A716-446655440000` represent the same UUID. Most systems normalize to lowercase for consistency.
- What is the nil UUID?
- The nil UUID is `00000000-0000-0000-0000-000000000000` — all 128 bits set to zero. It is used as a sentinel value to represent the absence of a UUID, similar to null. It should never be generated as a real identifier.
- How do I validate a UUID format?
- Use the regex `^[0-9a-f]{8}-[0-9a-f]{4}-[1-7][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$` for strict RFC compliance. The version nibble must be 1-7, and the variant nibble must be 8, 9, a, or b.
- Why does my database index perform poorly with UUIDs?
- UUID v4 is random, causing index entries to be inserted at random positions in B-tree pages. This leads to frequent page splits, index fragmentation, and poor cache utilization. Solutions include using UUID v7 (time-sorted), sequential UUIDs (ULID), or storing UUIDs as `BINARY(16)` with optimized collation.
- Is the UUID generator GDPR compliant?
- Yes. The UUID generator runs entirely in your browser using the Web Crypto API (`crypto.getRandomValues()`). No data is sent to any server, no cookies are set, and no analytics are triggered by the generation process itself. All computation happens client-side.
- What is the next UUID version after v7?
- RFC 9562 defines v8 as an experimental format where implementations can define custom semantics for the bit layout. There is also ongoing work on namespaced UUIDs and binary-to-text encoding optimizations. For practical purposes, v7 is the current recommended version for new systems.
- [1]RFC 9562: Universally Unique IDentifiers (UUIDs)
- [2]ITU-T Rec. X.667 | ISO/IEC 9834-8: UUID Generation Standard
- [3]pganalyze: UUIDs in PostgreSQL — Performance Implications
- [4]MDN Web Docs: crypto.getRandomValues()
- [5]PEP 645: Add uuid.uuid7() and uuid.uuid8() to Python Standard Library
- [6]ULID Specification — Universally Unique Lexicographically Sortable Identifier
- [7]uuid npm package — RFC 9562 compliant UUID generation
- [8]Percona: Storing UUID Values in MySQL
Last updated: June 15, 2026
UnByte — Independent Software Engineering
Every calculator references authoritative sources — Editorial policy