Générateur UUID
Générez des identifiants UUID v4 aléatoires instantanément pour bases de données et systèmes distribués
What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit label used to identify information across distributed systems without central coordination. Standardized by RFC 9562 (formerly RFC 4122), UUIDs guarantee practical uniqueness — the probability of collision is so low (1 in 2122 for v4) that they can be generated independently on any device without risk of duplicates. UUIDs are written as 32 hexadecimal digits in five groups separated by hyphens: 8-4-4-4-12.
UUID Version 4: Random Generation
This tool generates UUID version 4, which fills 122 of the 128 bits with cryptographically
random data. The remaining 6 bits encode the version (4 bits set to 0100) and
variant (2 bits set to 10). The result looks like:
xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx where the
"4" indicates version 4 and "y" is one of 8, 9, a, or b (indicating the RFC 4122 variant).
Version 4 is the most widely used UUID version because it requires no external state (no MAC address, no clock sequence, no namespace). It is suitable for primary keys, correlation IDs, session tokens, file identifiers, and any scenario where uniqueness is needed without coordination between generators.
Modern browsers provide crypto.randomUUID() which generates cryptographically secure
v4 UUIDs directly. This tool uses that API when available, falling back to
crypto.getRandomValues() for older environments — ensuring strong randomness in both cases.
UUID Versions Comparison
The UUID specification defines several versions, each with different trade-offs:
- v1 (Timestamp + MAC): Embeds creation time and hardware address. Sortable but leaks machine identity.
- v3 (MD5 namespace): Deterministic — same namespace + name always produces the same UUID. Uses MD5 (deprecated for security).
- v4 (Random): Fully random, no information leakage. Most popular for general-purpose use.
- v5 (SHA-1 namespace): Like v3 but uses SHA-1. Still deterministic and useful for consistent ID generation.
- v7 (Unix timestamp + random): New in RFC 9562. Time-sortable like v1 but uses random bits instead of MAC. Optimal for database indexing.
Choose v4 when you need maximum randomness and no information leakage. Choose v7 when your UUIDs will be used as database primary keys and you need time-based ordering for index efficiency.
UUIDs as Database Primary Keys
Using UUIDs as primary keys offers significant advantages in distributed systems: any node can generate IDs independently, merging datasets from different sources never produces conflicts, and IDs are unpredictable (no sequential guessing). However, there are trade-offs:
- Storage: 16 bytes vs 4 bytes for INT or 8 bytes for BIGINT. Modern databases handle this efficiently.
- Index fragmentation: Random v4 UUIDs cause B-tree page splits in clustered indexes. Mitigate with UUID v7 (time-ordered) or store as binary(16) instead of VARCHAR(36).
- Readability: Harder to communicate verbally or type manually. Use short IDs (NanoID) for user-facing identifiers and UUIDs for internal system identifiers.
Bulk Generation for Testing and Seeding
This tool supports generating up to 1000 UUIDs at once — useful for seeding test databases, generating fixture data, pre-allocating IDs for batch inserts, or creating test datasets for load testing. Each UUID in the bulk output is guaranteed unique (collision probability across 1000 random v4 UUIDs is approximately 1 in 1033).
Copy the bulk output directly into SQL INSERT statements, JSON arrays, CSV files, or
environment configuration files. The one-UUID-per-line format is designed for easy integration
with command-line tools like xargs, awk, and sed.
Code Examples
Generating UUIDs in different languages
// JavaScript (modern browsers & Node.js 19+)
const uuid = crypto.randomUUID();
// → "550e8400-e29b-41d4-a716-446655440000"
// Fallback for older environments
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}Using UUIDs as PostgreSQL primary keys
-- PostgreSQL: native UUID type with gen_random_uuid()
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email VARCHAR(255) UNIQUE NOT NULL,
created_at TIMESTAMPTZ DEFAULT NOW()
);
-- Insert without specifying ID — auto-generated
INSERT INTO users (email) VALUES ('alice@example.com');Standards & Specifications
- RFC 9562 — Current UUID specification (2024) defining versions 1–8, replacing RFC 4122
- RFC 4122 (legacy) — Original UUID specification (2005) — still widely referenced in documentation and libraries
Questions Fréquentes
Les UUID v4 sont-ils uniques ?
En pratique, oui. UUID v4 a 122 bits d'aléatoire avec 5.3×10^36 valeurs possibles.
Puis-je utiliser des UUIDs comme clés primaires ?
Oui. Les UUIDs permettent la génération d'ID côté client. Considérez UUID v7 pour de meilleurs index.
Différence entre UUID et GUID ?
C'est la même chose. UUID est le terme officiel RFC 9562. GUID est le terme Microsoft.
La génération est-elle sécurisée ?
Oui. Utilise crypto.getRandomValues() pour une aléatoire cryptographiquement sûre.