ID
Developer
UUID Generator FAQ — UUID v4, GUID & Unique Identifiers
Everything about UUIDs: how they work, UUID v4 vs v7, collision probability, and when to use UUIDs vs auto-increment IDs in databases.
Q1 What is a UUID?
A UUID (Universally Unique Identifier) is a 128-bit identifier formatted as 32 hexadecimal digits in 5 groups separated by hyphens:
550e8400-e29b-41d4-a716-446655440000. UUIDs are designed to be globally unique without a central authority. Generate them instantly with the UUID Generator.
Q2 What is the difference between UUID and GUID?
UUID and GUID are the same thing. UUID (Universally Unique Identifier) is the standard term used in RFC 4122. GUID (Globally Unique Identifier) is Microsoft's term used in Windows and .NET. They share the same format, size (128 bits), and generation algorithms.
Q3 What is UUID v4?
UUID v4 is randomly generated — 122 of the 128 bits are random (6 bits indicate version and variant). This makes it the simplest and most widely used version. The probability of collision is astronomically low. Generate UUID v4s with the UUID Generator.
Q4 Can UUIDs collide?
UUID v4 collisions are theoretically possible but practically impossible. With 122 random bits, you would need to generate about 2.71 quintillion UUIDs to have a 50% chance of one collision. Even generating 1 billion UUIDs per second, it would take about 86 years to reach that point.
Q5 Should I use UUID or auto-increment ID?
Use UUIDs when: (1) you need IDs before database insertion; (2) merging data from multiple databases; (3) IDs are exposed in URLs (UUIDs don't reveal count); (4) distributed systems. Use auto-increment when: (1) storage space matters (4 bytes vs 16); (2) index performance is critical; (3) you need natural ordering.
Q6 What is UUID v7?
UUID v7 (RFC 9562, 2024) embeds a Unix timestamp in the first 48 bits, making UUIDs naturally sortable by creation time. The remaining bits are random. UUID v7 is ideal for database primary keys because it maintains B-tree index locality (unlike random v4) while being globally unique.
Q7 How do I generate a UUID in JavaScript?
Modern browsers:
crypto.randomUUID() (built-in, no dependencies). Node.js 19+: same API. Older environments: import { v4 as uuidv4 } from 'uuid'; uuidv4(). Never use Math.random() for UUIDs — it is not cryptographically secure.
Q8 How do I generate a UUID in Python?
Use the built-in
uuid module: import uuid; str(uuid.uuid4()) for a random UUID v4. For UUID v1 (time-based): uuid.uuid1(). For a UUID from a name: uuid.uuid5(uuid.NAMESPACE_DNS, 'example.com').
Q9 What are the different UUID versions?
UUID v1: timestamp + MAC address (leaks info). UUID v3: MD5 hash of a name. UUID v4: random (most common). UUID v5: SHA-1 hash of a name. UUID v6: reordered v1 for sortability. UUID v7: timestamp + random (recommended for new projects). UUID v8: custom/vendor-defined.
Q10 How do I store UUIDs in a database?
Best: use native UUID type (PostgreSQL
uuid, MySQL 8 BINARY(16)). Avoid storing as VARCHAR(36) — it wastes space and is slower to index. PostgreSQL: CREATE TABLE users (id UUID DEFAULT gen_random_uuid() PRIMARY KEY).
Q11 Are UUIDs sequential?
UUID v4 is completely random with no ordering. UUID v1 and v6 contain timestamps but in different byte positions. UUID v7 is designed to be time-ordered — the first 48 bits are a Unix timestamp, making them sortable by creation time. Use v7 when you need both uniqueness and natural ordering.
Q12 How long is a UUID?
A UUID is 128 bits (16 bytes) of data. In standard string format with hyphens: 36 characters. Without hyphens: 32 hex characters. In binary: 16 bytes. In Base64: 22 characters. Choose the format based on storage and display needs.
Q13 Can I use UUID as a URL slug?
Yes, but UUIDs are long (36 characters) and ugly in URLs. Alternatives: use short UUIDs (Base62 encoded, ~22 chars), NanoID (21 chars by default, URL-safe), or ULID (26 chars, sortable). If you use UUIDs in URLs, strip the hyphens to save 4 characters.
Q14 What is NanoID?
NanoID is a tiny, URL-friendly unique string ID generator. Default: 21 characters using A-Za-z0-9_-. It is smaller than UUID (21 vs 36 chars), URL-safe by default, and cryptographically secure.
Q15 What is ULID?
ULID (Universally Unique Lexicographically Sortable Identifier) is a 128-bit identifier like UUID but encoded as 26 Crockford Base32 characters. The first 10 characters encode a millisecond timestamp, making ULIDs sortable. ULIDs are case-insensitive and URL-safe.
Q16 How do I generate bulk UUIDs?
The UUID Generator lets you generate multiple UUIDs at once. In CLI: use a loop with uuidgen (macOS/Linux). In Python:
[str(uuid.uuid4()) for _ in range(100)].
Q17 Are UUIDs case-sensitive?
No. RFC 4122 specifies that UUIDs should be output in lowercase but must be accepted in a case-insensitive manner. PostgreSQL and most databases treat them case-insensitively.
Q18 What is a nil UUID?
The nil UUID is all zeros:
00000000-0000-0000-0000-000000000000. It is used as a sentinel value meaning "no UUID" or "not set". RFC 9562 also defines a max UUID (all ones). Both are reserved and should not be generated randomly.
Q19 How do I validate a UUID format?
Regex:
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i. To validate specific versions, check the 13th character (version) and 17th character (variant). In Python: try uuid.UUID(string) and catch ValueError if invalid.
Q20 Should I use UUID v4 or v7 for my database?
For new projects, prefer UUID v7. Its time-ordered nature means sequential inserts go to the same B-tree leaf page, dramatically reducing index fragmentation and improving write performance. UUID v4's randomness scatters inserts across the index, causing page splits. UUID v7 gives you uniqueness plus performance.
Free Developer Tools
All tools run in your browser — no signup, no data sent to servers.