Basics
What is a UUID? โพ
A UUID (Universally Unique Identifier) is a 128-bit label used to uniquely identify information in computer systems. It is represented as 32 hex digits in the format
8-4-4-4-12. UUIDs are standardised by RFC 9562 and designed to be globally unique without a central registration authority.What is the difference between UUID and GUID? โพ
Nothing โ they are identical. GUID (Globally Unique Identifier) is simply Microsoft's name for UUID. Both use the same 128-bit format, follow RFC 9562, and are completely interchangeable. Microsoft uses the term in .NET, Windows APIs, and SQL Server.
How many UUIDs are possible? โพ
There are 2128 possible UUIDs โ approximately 340 undecillion (340 ร 1036). For UUID v4 specifically, 122 bits are random, giving 2122 โ 5.3 ร 1036 unique values. Collisions are negligible in practice.
Versions
Which UUID version should I use? โพ
v4 for general use (session tokens, API keys, most IDs). v7 for database primary keys (time-ordered, index-friendly). v5 for deterministic IDs from known data. Avoid v1 in new systems โ v7 is strictly better.
Why is UUID v7 better than v4 for databases? โพ
UUID v4 is random, causing index fragmentation in clustered B-tree indexes (MySQL InnoDB, SQL Server). New rows are inserted at random positions, causing page splits and poor cache performance. UUID v7 is time-ordered โ it inserts at the end of the index like an auto-increment integer, giving the same performance while retaining UUID benefits.
What is a Nil UUID? โพ
The Nil UUID is
00000000-0000-0000-0000-000000000000 โ all 128 bits zero. It is defined in RFC 9562 and used as a null/empty identifier placeholder, similar to null in programming. Never use it as a real entity identifier.Security
Are UUIDs generated here safe to use in production? โพ
Yes. UUIDCore uses
crypto.getRandomValues() (Web Crypto API) โ a cryptographically secure random number generator. All generation happens in your browser. Nothing is transmitted to our servers.Can UUID v4 be guessed or predicted? โพ
No. With 122 bits of cryptographic randomness, UUID v4 cannot be practically predicted or brute-forced. This is true only when generated using a CSPRNG โ never use Math.random() for UUID generation in production.
Is it safe to expose UUIDs in URLs? โพ
Yes โ UUID v4 is safe to expose in URLs. Unlike sequential integers, random UUIDs prevent enumeration attacks. Ensure your access control validates permissions โ the UUID itself is not an access control mechanism.
Databases
How should I store UUIDs in PostgreSQL? โพ
Use the native
UUID type โ it stores as 16 bytes (more efficient than VARCHAR(36)). For v4: DEFAULT gen_random_uuid(). For v7: use the pg_uuidv7 extension or generate in application code.How should I store UUIDs in MySQL? โพ
Store as
BINARY(16) for best performance. Use UUID_TO_BIN(uuid, 1) to insert and BIN_TO_UUID(col, 1) to retrieve. The 1 flag swaps the byte order for better index performance. Avoid VARCHAR(36) โ it uses 2ร the storage.UUID vs auto-increment โ which should I use? โพ
Use UUID when: IDs are generated client-side, you merge data from multiple databases, you want to prevent enumeration, or you are building distributed systems. Use auto-increment when: single database, maximum index performance, no need for global uniqueness. A popular hybrid: UUID as public API identifier, auto-increment as internal primary key.
Technical
How do I validate a UUID? โพ
Use the regex:
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i. Or use our UUID Validator tool which also identifies the version and variant.What is RFC 9562? โพ
RFC 9562 is the current IETF UUID standard, published May 2024. It supersedes RFC 4122 and adds UUID versions 6, 7, and 8 while clarifying existing versions 1โ5. All UUIDs generated by UUIDCore conform to RFC 9562.
What is the difference between UUID v3 and v5? โพ
Both are name-based and deterministic, but v3 uses MD5 (cryptographically broken) and v5 uses SHA-1. Always prefer UUID v5 over v3. Neither should be used as a cryptographic security mechanism โ they are for generating reproducible identifiers, not secure tokens.