Generate universally unique identifiers (UUIDs) in various formats. Supports UUID v1, v4, and v7 with different formatting options for your development needs.
Example: 51043126-0197-1-9ee3-fcdcaacc0530
Example: a19ef855-fdd2-4d7b-a542-e5343c461911
Example: 01975104-3127-7df4-bfd4-b00668cc1d88
Generate UUID v1, v4, and v7 for different use cases.
Choose from multiple formatting options and cases.
Generate up to 100 UUIDs at once for bulk operations.
Copy individual UUIDs or all at once for easy use.
A Universally Unique Identifier (UUID) is a 128-bit number used to identify information in computer systems. UUIDs are designed to be unique across space and time without requiring a central registration authority.
With proper implementation, the probability of generating duplicate UUIDs is negligible. For UUID v4, there are 2^122 possible values (5.3 Γ 10^36), making collisions extremely unlikely.
Version | Basis | Sortable | Privacy |
---|---|---|---|
v1 | Timestamp + MAC | Yes | Low |
v4 | Random | No | High |
v7 | Timestamp + Random | Yes | High |
UUIDs as primary keys eliminate the need for centralized ID generation in distributed systems.
UUIDs enable independent ID generation across microservices without coordination.
UUIDs eliminate ID conflicts when replicating data across multiple databases or regions.
UUIDs can be generated client-side, reducing server round trips and enabling offline operations.
UUIDs provide security through obscurity and prevent enumeration attacks on sequential IDs.
26-character string that's both unique and lexicographically sortable. Better database performance than UUID v4.
Twitter's 64-bit ID scheme: timestamp + machine ID + sequence. Sortable and fits in a long integer.
URL-safe, compact alternative to UUID. 21 characters, URL-friendly alphabet, faster generation.
Type | Size | Sortable | DB Perf |
---|---|---|---|
UUID v4 | 128-bit | No | Poor |
UUID v7 | 128-bit | Yes | Good |
ULID | 128-bit | Yes | Good |
Snowflake | 64-bit | Yes | Excellent |
nanoid | Variable | No | Fair |
// Modern browsers const uuid = crypto.randomUUID(); console.log(uuid); // e.g., "123e4567-e89b-12d3-a456-426614174000" // Polyfill for older browsers function generateUUIDv4() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { const r = Math.random() * 16 | 0; const v = c === 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); }
const { randomUUID } = require('crypto'); const uuid = randomUUID(); // Or using uuid package const { v4: uuidv4, v7: uuidv7 } = require('uuid'); const uuid4 = uuidv4(); const uuid7 = uuidv7();
import uuid # UUID v4 (random) uuid4 = uuid.uuid4() print(str(uuid4)) # with hyphens print(uuid4.hex) # without hyphens # UUID v1 (timestamp + MAC) uuid1 = uuid.uuid1() # Convert to different formats uuid_bytes = uuid4.bytes uuid_int = uuid4.int
import java.util.UUID; // Generate random UUID UUID uuid = UUID.randomUUID(); System.out.println(uuid.toString()); // Parse from string UUID parsed = UUID.fromString("123e4567-e89b-12d3-a456-426614174000"); // Get components long mostSigBits = uuid.getMostSignificantBits(); long leastSigBits = uuid.getLeastSignificantBits();
-- Enable extension CREATE EXTENSION IF NOT EXISTS "uuid-ossp"; -- Generate UUID v4 SELECT uuid_generate_v4(); -- Table with UUID primary key CREATE TABLE users ( id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), email VARCHAR(255) UNIQUE NOT NULL );
-- Generate UUID SELECT UUID(); -- Binary storage for performance CREATE TABLE users ( id BINARY(16) PRIMARY KEY DEFAULT (UUID_TO_BIN(UUID())), email VARCHAR(255) UNIQUE NOT NULL );
A: UUIDs are designed to be unique with extremely high probability. For UUID v4, the chance of collision is negligible (1 in 5.3 Γ 10^36). However, poor random number generation or implementation bugs can increase collision risk.
A: For most applications, use UUID v4 (random). If you need chronological sorting and don't mind revealing timestamp information, consider UUID v7. Avoid UUID v1 unless you specifically need MAC address information and privacy isn't a concern.
A: Random UUIDs (v4) can impact database performance due to random insertion patterns causing index fragmentation. Use binary storage, consider UUID v7 or ULID for better performance, and monitor index maintenance needs.
A: UUIDs provide security through obscurity but shouldn't be your only security measure. They prevent enumeration attacks but don't replace proper authentication and authorization. Never rely solely on UUID unpredictability for security.
A: Store UUIDs in binary format (16 bytes) rather than as strings (36 characters). Most databases have native UUID types or BINARY(16) columns. This reduces storage space and improves query performance significantly.
A: Yes! Client-side UUID generation is safe and recommended. It reduces server load, enables offline functionality, and improves user experience with optimistic UI updates. Ensure you're using a cryptographically secure random source.
A: UUID and GUID are essentially the same thing. GUID (Globally Unique Identifier) is Microsoft's terminology for the same 128-bit identifier concept. The format and generation methods are identical, just different naming conventions.
A: Yes! Consider ULID for sortable identifiers, Snowflake IDs for high-performance systems, nanoid for URL-friendly IDs, or Cuid for collision-resistant identifiers. Choose based on your specific requirements for sortability, size, and performance.