Online UUID Generator | Generate UUIDs v1, v3-v7 for Free
What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit identifier used in computer systems for uniquely identifying information. UUIDs are standardized by RFC 4122, and thanks to their enormous entropy, they guarantee a practically zero probability of collision – meaning that two independently generated UUIDs will almost certainly be unique.
A UUID has a standard format: xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx, where each x is a hexadecimal digit (0-9, a-f), M indicates the UUID version, and N indicates the variant.
UUID Versions
UUID v1 (Timestamp + MAC Address)
UUID v1 is based on the current timestamp and a random value (in browsers, instead of a MAC address). It uses 100-nanosecond intervals since October 15, 1582 (Gregorian calendar).
Usage:
- Situations where you need chronological sorting of UUIDs
- Debugging and logging (UUID contains information about creation time)
- Distributed systems with time synchronization
Example: 6ba7b810-9dad-11d1-80b4-00c04fd430c8
Advantages:
- UUIDs can be sorted chronologically by creation time
- Useful for auditing and debugging
- Contains timestamp information
Disadvantages:
- Potential security risk – contains a timestamp
- In browsers, it does not contain a real MAC address (replaced by a random value)
- Poor DB locality (timestamp is in low-order bits)
UUID v3 (MD5 hash)
UUID v3 is generated using an MD5 hash of a namespace UUID and a name. It’s deterministic – the same namespace + name will always produce the same UUID.
Usage:
- Converting URLs, DNS names, or other identifiers to UUIDs
- Situations where you need reproducible UUIDs
- Mapping between different identification systems
Example: a3bb189e-8bf9-3888-9912-ace4e6543002
Advantages:
- Deterministic (same input = same output)
- Ideal for converting known identifiers
- No collision for different inputs
Disadvantages:
- MD5 is an outdated algorithm (prefer v5)
- Requires a namespace and a name
- Cannot retrieve the original input
UUID v4 (Random) - RECOMMENDED
The most commonly used UUID version. UUID v4 is generated purely randomly using a cryptographically secure random number generator (crypto.getRandomValues()).
Usage:
- Database primary keys
- Session IDs
- Unique file names
- API tokens
- General purposes where you need a guaranteed unique ID
Example: f47ac10b-58cc-4372-a567-0e02b2c3d479
Advantages:
- Maximum entropy and security
- No dependency on time or system parameters
- Simplest implementation
Collision Probability: When generating 1 billion UUIDs per second for 100 years, the chance of a collision is approximately 0.00000006%.
UUID v5 (SHA-1 hash)
UUID v5 is similar to v3, but uses SHA-1 instead of MD5. A more modern and secure alternative to v3.
Usage:
- Same as v3, but with better security
- Preferred over v3 for new projects
- Generating UUIDs from URLs, DNS names, OIDs, X.500 DN
Example: 886313e1-3b8a-5372-9b90-0c9aee199e5d
Advantages:
- Deterministic
- SHA-1 is more robust than MD5
- Suitable for mapping between systems
Disadvantages:
- SHA-1 is also considered outdated (but still more secure than MD5)
- Requires a namespace and a name
UUID v6 (Ordered Timestamp)
UUID v6 is an enhanced version of v1 with reordered time bits for better database indexing. Designed to address locality issues in databases.
Usage:
- Database primary keys with time-ordering
- Systems requiring chronological ordering and DB performance
- A more modern alternative to v1
Example: 1ec9414c-232a-6b00-b3c8-9e6bdeced846
Advantages:
- Better DB locality than v1 (timestamp in high-order bits)
- Chronological ordering
- Compatible with UUID standard
Disadvantages:
- Less commonly used than v1/v4
- Still contains time information (security risk)
UUID v7 (Unix timestamp)
UUID v7 uses a Unix timestamp (milliseconds since 1970) + random bits. It’s the newest UUID version with the best database locality.
Usage:
- Modern database primary keys
- Systems requiring performance + time ordering
- Replacement for v1/v6 in new projects
Example: 017f22e2-79b0-7cc3-98c4-dc0c0c07398f
Advantages:
- Best DB locality among all versions
- Unix timestamp is standard
- Combines the benefits of randomness and time ordering
Disadvantages:
- Relatively new specification (RFC 4122bis)
- Less supported in legacy systems
Which UUID Version to Use?
Decision Guide
Do you need maximum security and randomness? → Use UUID v4 (most common choice)
Do you need time ordering and DB performance? → Use UUID v7 (modern) or UUID v6 (standard)
Do you need reproducible UUIDs from existing identifiers? → Use UUID v5 (SHA-1) or UUID v3 (MD5, legacy)
Do you need a timestamp and an audit trail? → Use UUID v1 (legacy, poorer DB performance)
Databases
For new projects: UUID v7 or v4
- v7 is ideal for time ordering + performance
- v4 for maximum randomness without time information
For legacy systems: UUID v1 or v6
- v6 has better DB locality than v1
- v1 is widely supported
Advantages of UUID as a primary key:
- Global uniqueness – You can merge data from different databases without conflict
- Security – Unlike sequential IDs (1, 2, 3…), future values cannot be guessed
- Distributed systems – UUIDs can be generated independently on multiple servers without coordination
- Database merging – No conflicts arise when merging two databases
Disadvantages:
- Larger size (16 bytes vs 4-8 bytes for integer)
- Slower indexing in some databases (use v6/v7 for better performance)
- Less human-readable
API and Web Services
- REST API – Unique identifiers for resources
- GraphQL – Global identifiers for nodes
- Webhooks – Tracking requests and responses
- Tokens – Session IDs, refresh tokens
Files and Storage
- File names – Preventing collisions during upload
- S3/Cloud Storage – Unique paths to objects
- Cache keys – Identifiers in cache systems
Frontend Applications
- React/Vue components – Unique keys for lists
- Temporary IDs – IDs before saving to the database
- Local storage – Keys for stored data
- Offline-first applications – Generating IDs without server connection
Advanced Generator Features
Generating UUIDs with Custom Time
For time-based versions (v1, v6, v7), you can select any timestamp using the date-time picker. This is useful for:
Testing:
- Simulating UUIDs created in the past
- Testing time-ordering in databases
- Reproducing UUIDs for debugging
Data Migration:
- Generating UUIDs with historical timestamps
- Backfilling data with correct timestamp values
- Importing data from different time periods
Audit and compliance:
- Reconstructing UUIDs based on record creation time
- Retroactive identifier generation
Example usage:
- Select version v1, v6, or v7
- Set the date and time using the date-time picker
- Generate UUIDs with your custom timestamp
Hash-based UUID (v3, v5)
For deterministic UUIDs, you can use versions v3 (MD5) or v5 (SHA-1):
How to use:
- Select a namespace according to the type of your identifier
- Enter the name/value
- Generate the UUID
Examples:
| Namespace | Name (input) | Usage |
|---|---|---|
| DNS | example.com | Convert domain name to UUID |
| DNS | google.com | Each website has a unique UUID |
| URL | https://example.com/page | Convert URL to UUID |
| URL | https://api.example.com/users/123 | API endpoint as UUID |
| OID | 1.3.6.1.4.1.343 | Object Identifier to UUID |
| X.500 | CN=John Doe,O=Company | Distinguished Name to UUID |
Important properties:
- ✅ Deterministic: Same input = always same UUID
- ✅ Reproducible: You can recreate the UUID anytime
- ✅ Consistent: Same UUID across different systems
- ❌ Cannot decode: Original name cannot be retrieved from UUID
- ℹ️ Single UUID: For v3/v5, only one UUID is generated (same input = same output)
Practical usage:
// Example: Convert URL to UUID v5
Namespace: URL
Name: https://example.com/api/users/123
Result: 886313e1-3b8a-5372-9b90-0c9aee199e5d
// Same input = always same UUID
Namespace: DNS
Name: google.com
Result: always the same UUID for google.com
How to Safely Use UUIDs?
Cryptographic Security
Our generator uses crypto.getRandomValues(), which is a cryptographically secure random number generator. Unlike Math.random(), which is predictable and unsuitable for security purposes, crypto.getRandomValues() provides real entropy suitable for:
- Generating security tokens
- Session IDs
- API keys
- Cryptographic applications
Comparison of UUID Versions
| Version | Basis | Collisions | Time-Ordering | DB Performance | Usage |
|---|---|---|---|---|---|
| v1 | Timestamp + MAC | Low | ✅ Yes | ❌ Worse | Legacy, audit |
| v3 | MD5 hash | None (deterministic) | ❌ No | ⚠️ Medium | Conversions (legacy) |
| v4 | Random | Extremely low | ❌ No | ⚠️ Medium | General purpose |
| v5 | SHA-1 hash | None (deterministic) | ❌ No | ⚠️ Medium | Conversions (recommended) |
| v6 | Ordered timestamp | Low | ✅ Yes | ✅ Better | Modern DBs with time |
| v7 | Unix timestamp | Low | ✅ Yes | ✅ Best | New projects |
UUID vs Other Identifiers
| Type | Size | Collisions | Time-Ordering | Usage |
|---|---|---|---|---|
| Auto-increment ID | 4-8 bytes | Guaranteed unique within table | ❌ | Simple apps, local DB |
| UUID v4 | 16 bytes | Practically impossible | ❌ | Distributed systems, API |
| UUID v7 | 16 bytes | Practically impossible | ✅ | Modern DBs with performance |
| ULID | 16 bytes | Practically impossible | ✅ | UUID + lexicographical sorting |
| Snowflake ID | 8 bytes | Guaranteed unique with proper config | ✅ | Twitter, distributed systems |
| NanoID | Configurable | Depends on length | ❌ | URL-friendly IDs |
Implementation in Different Languages
JavaScript/TypeScript
// UUID v4 - Easiest way (modern browsers)
const uuid = crypto.randomUUID();
// UUID v4 - Manual implementation
function generateUUIDv4() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
const r = (crypto.getRandomValues(new Uint8Array(1))[0] & 0x0f) >> (c === 'x' ? 0 : 2);
const v = c === 'x' ? r : (r & 0x3) | 0x8;
return v.toString(16);
});
}
// UUID v7 - Recommended for databases
function generateUUIDv7() {
const timestamp = Date.now();
const timeHi = (timestamp >> 16).toString(16).padStart(8, '0');
const timeLow = (timestamp & 0xFFFF).toString(16).padStart(4, '0');
const randomBytes = crypto.getRandomValues(new Uint8Array(10));
const randomHex = Array.from(randomBytes)
.map(b => b.toString(16).padStart(2, '0'))
.join('');
return `${timeHi}-${timeLow}-7${randomHex.substr(0, 3)}-${randomHex.substr(3, 4)}-${randomHex.substr(7)}`;
}
Python
import uuid
# UUID v4
uuid_v4 = str(uuid.uuid4())
# Output: '6ba7b810-9dad-11d1-80b4-00c04fd430c8'
# UUID v1
uuid_v1 = str(uuid.uuid1())
Java
import java.util.UUID;
// UUID v4
String uuidV4 = UUID.randomUUID().toString();
PHP
// UUID v4 (PHP 7+)
function generateUUID() {
return sprintf('%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand(0, 0xffff), mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0x0fff) | 0x4000,
mt_rand(0, 0x3fff) | 0x8000,
mt_rand(0, 0xffff), mt_rand(0, 0xffff), mt_rand(0, 0xffff)
);
}
C#
using System;
// UUID v4
Guid uuid = Guid.NewGuid();
string uuidString = uuid.ToString();
Best Practices
Storing UUIDs in a Database
PostgreSQL:
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT NOW()
);
MySQL 8.0+:
CREATE TABLE users (
id BINARY(16) PRIMARY KEY DEFAULT (UUID_TO_BIN(UUID())),
email VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
Tip: In MySQL, store UUIDs as BINARY(16) instead of CHAR(36) to save space and for faster indexing.
UUID Validation
function isValidUUID(uuid) {
const regex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
return regex.test(uuid);
}
UUID Conversion
// Remove hyphens
const compact = uuid.replace(/-/g, '');
// Add hyphens back
function formatUUID(compactUuid) {
return [
compactUuid.substring(0, 8),
compactUuid.substring(8, 12),
compactUuid.substring(12, 16),
compactUuid.substring(16, 20),
compactUuid.substring(20, 32)
].join('-');
}
Troubleshooting
UUID v3/v5 is not working
Problem: After selecting v3 or v5, nothing is generated
Solution:
- ✅ Check that you have filled in the “Name” field - it is mandatory!
- ✅ Select the correct namespace based on your input type
- ✅ Examples of valid inputs:
- DNS:
example.com,google.com - URL:
https://example.com/page - Any text:
my-application-v1
- DNS:
Tip: Try a simple value like test and the DNS namespace first.
Time-based UUID (v1, v6, v7) has a strange time
Problem: The generated UUID has an unexpected timestamp
Solution:
- ✅ Check the date-time picker - is the correct time set?
- ✅ The date-time picker uses your local timezone
- ✅ Leave the date-time picker empty for the current time
UUID cannot be copied
Problem: The “Copy All” button does not work
Solution:
- ✅ Check that you have generated UUIDs (they are not empty)
- ✅ Some browsers require HTTPS for the clipboard API
- ✅ Alternatively, select the text in the textarea and copy manually (Ctrl+C)
Frequently Asked Questions (FAQ)
Can UUID collisions occur?
Theoretically yes, but the probability is astronomically small. When generating 1 billion UUID v4s per second for 100 years, the chance of a collision is approximately 0.00000006%. In practice, a collision will almost never happen.Is UUID suitable as a primary key in a database?
It depends on the use case. UUID is ideal for distributed systems and situations where you need global uniqueness. For simple applications with a single database, auto-increment might be more efficient.Are UUIDs generated by this tool secure?
Yes, we use the Web Crypto API (`crypto.getRandomValues()`), which provides cryptographically secure random values. Everything happens locally in your browser.What is the difference between UUID versions?
- **v1**: Timestamp + MAC/random - chronological sorting, poorer DB performance - **v3/v5**: Hash-based - deterministic, for converting known identifiers - **v4**: Random - most secure, most commonly used - **v6**: Reordered timestamp - better DB performance than v1 - **v7**: Unix timestamp - best DB performance + time orderingWhich UUID version should I use?
For most cases, use **v4** (random). For databases with time ordering, use **v7** (modern) or **v6** (standard). For converting known identifiers (URL, DNS), use **v5** (SHA-1).Can I use UUIDs for tokens and API keys?
UUID v4 is suitable for session IDs and similar tokens. For API keys, consider using longer random strings (e.g., 256-bit values) or specialized libraries.How large are UUIDs?
A UUID is 128 bits (16 bytes). In string format with hyphens, it takes up 36 characters. Without hyphens, it's 32 hexadecimal characters.Alternatives to UUIDs
ULID (Universally Unique Lexicographically Sortable Identifier)
- 128-bit ID (same as UUID)
- Lexicographically sortable by creation time
- More compact representation (26 characters instead of 36)
- Case-insensitive base32 encoding
Example: 01ARZ3NDEKTSV4RRFFQ69G5FAV
NanoID
- Smaller size than UUID (21 characters by default)
- URL-friendly (no special characters)
- Faster generation
- Configurable length and alphabet
Example: V1StGXR8_Z5jdHi6B-myT
Snowflake ID (Twitter)
- 64-bit ID (smaller than UUID)
- Time-sortable
- Contains worker ID and sequence number
- Requires centralized configuration
Example: 1234567890123456789
Performance and Optimization
Generation Speed
Our generator can generate:
- 1 UUID: < 1 ms
- 100 UUIDs: ~10-20 ms
- 1000 UUIDs: ~100-200 ms
Performance Tips
- Batch Generation – If you need many UUIDs, generate them all at once instead of one by one
- Storing in DB – Index UUID columns for fast lookups
- Compression – Store UUIDs in binary form (16 bytes) instead of a string (36 bytes)
- Caching – In some cases, you can pre-generate and cache UUIDs
For Developers
UUID v4 Structure
xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
| | | | |
| | | | └─ 48 bits of random data (node)
| | | └────── 16 bits of random data with variant (clock_seq)
| | └─────────── 12 bits of random data + 4 bits of version (time_hi_and_version)
| └──────────────── 16 bits of random data (time_mid)
└───────────────────────── 32 bits of random data (time_low)
- Version (4 bits): always
0100(binary) =4(hex) - Variant (2-3 bits): always
10(binary) for RFC 4122
Testing UUIDs
// Jest test
describe('UUID Generator', () => {
test('generates valid UUID v4', () => {
const uuid = generateUUIDv4();
const regex = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
expect(regex.test(uuid)).toBe(true);
});
test('generates unique UUIDs', () => {
const uuid1 = generateUUIDv4();
const uuid2 = generateUUIDv4();
expect(uuid1).not.toBe(uuid2);
});
});
Security Aspects
What NOT to Do with UUIDs
❌ Do not use UUID v1 for sensitive applications – It contains a timestamp, which can be a security risk
❌ Do not use Math.random() to generate UUIDs – It is not cryptographically secure
❌ Do not rely on UUIDs for authorization – UUIDs can be guessed (though with an extremely low probability)
❌ Do not store UUIDs in cookies without encryption – Use signed cookies or JWTs
What to DO
✅ Use UUID v4 for most cases – Highest entropy and security
✅ Combine UUIDs with other security measures – For session management, use HTTPS, HttpOnly cookies, and short expiration
✅ Validate UUIDs on the server – Always check the format and version of the UUID
✅ Use cryptographically secure random number sources – crypto.getRandomValues() in the browser, /dev/urandom on Linux
Interesting Facts
- Number of possible UUID v4s: 2^122 ≈ 5.3 × 10^36 (340 undecillions)
- Collision needed: For a 50% chance of collision, you need to generate 2.71 × 10^18 UUIDs (2.71 quintillions)
- Size of all possible UUIDs: If we stored each UUID as 16 bytes, the entire space would occupy 85 zettabytes (85 billion terabytes)
- Origin: UUID was standardized as part of the DCE (Distributed Computing Environment) in 1990