UUID & GUID Generator – Random UUID v4 Online
Generate random UUIDs and GUIDs instantly. Bulk generation, format options, and UUID validator — everything runs in your browser.
Validate UUID
What Is a UUID?
A UUID (Universally Unique Identifier), also called a GUID (Globally Unique Identifier), is a 128-bit label used to uniquely identify objects in computer systems. A UUID is formatted as 32 hexadecimal digits displayed in five groups separated by hyphens: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. The standard format looks like 550e8400-e29b-41d4-a716-446655440000.
The key property of a UUID is that it can be generated independently on any machine without coordination with a central authority, and the probability of two UUIDs being the same is astronomically small — roughly 1 in 5.3 × 10³⁶ for v4. This makes UUIDs ideal for distributed systems, database primary keys, session tokens, and anywhere a globally unique identifier is needed.
UUID v4 vs UUID v7 – Which Should You Use?
UUID v4 (Random)
UUID v4 is the most widely used version. It consists of 122 randomly generated bits, making it unpredictable and non-guessable. It is the default choice for most applications — session tokens, API keys, user IDs, file names, and any context where you need a random, unique identifier. The downside is that v4 UUIDs are not sortable by creation time, which can cause index fragmentation in databases when used as primary keys.
UUID v7 (Time-Ordered)
UUID v7 (RFC 9562, finalized 2024) embeds a Unix millisecond timestamp in the first 48 bits, making UUIDs sortable by creation time. This is a major advantage for database primary keys — time-ordered UUIDs cause far less index fragmentation than random v4 UUIDs, leading to better write performance on B-tree indexes. UUID v7 is increasingly recommended as the default for new database schemas. If you are using PostgreSQL, MySQL 8+, or any database with UUID primary keys, v7 is worth adopting.
UUID vs GUID – Are They the Same Thing?
Yes, in practice, UUID and GUID refer to the same thing. UUID is the RFC standard term (RFC 4122 / RFC 9562), while GUID (Globally Unique Identifier) is Microsoft's term used in Windows, .NET, SQL Server, and COM programming. Both use the same 128-bit format and the same generation algorithms. When you call Guid.NewGuid() in C# or NEWID() in SQL Server, the result is a UUID-compatible identifier. The only practical difference is that Microsoft sometimes formats GUIDs with surrounding braces: {550e8400-e29b-41d4-a716-446655440000}.
How to Generate a UUID in Code
JavaScript / Node.js
crypto.randomUUID() — built into modern browsers and Node.js 14.17+. No library needed. For older environments, use the uuid npm package: import { v4 as uuidv4 } from 'uuid'; uuidv4();
Python
import uuid; str(uuid.uuid4()) — Python's standard library includes UUID generation. For v5 (namespace-based): uuid.uuid5(uuid.NAMESPACE_DNS, 'example.com')
Java
UUID.randomUUID().toString() — built into java.util.UUID, no external dependency required.
C# / .NET
Guid.NewGuid().ToString() — generates a new random GUID. Use .ToString("B") for the braces format or .ToString("N") for the no-hyphens format.
Go
Use the github.com/google/uuid package: uuid.New().String(). Go's standard library does not include UUID generation natively.
PHP / Laravel
In PHP: Str::uuid() in Laravel, or use ramsey/uuid for full RFC 4122 support. In raw PHP 8.3+: Uuid::v4() via Symfony's UID component.
Using UUIDs in Databases
PostgreSQL
PostgreSQL has a native UUID column type stored as 16 bytes. Use gen_random_uuid() (built-in since PostgreSQL 13) or the pgcrypto extension's uuid_generate_v4(). For default values: id UUID DEFAULT gen_random_uuid().
MySQL / MariaDB
Use UUID() for v1 or store v4 as CHAR(36) or as a 16-byte BINARY(16) for storage efficiency. MySQL 8.0+ supports UUID_TO_BIN(UUID(), 1) to create time-ordered binary UUIDs for better index performance.
SQL Server
SQL Server uses UNIQUEIDENTIFIER as the GUID type and NEWID() to generate random GUIDs. For sequential GUIDs with better index performance, use NEWSEQUENTIALID() as a column default — it generates time-ordered GUIDs similar to UUID v7.
MongoDB
MongoDB uses ObjectID as its default _id, but you can use UUIDs instead. Store as BinData(3, ...) or BinData(4, ...) (UUID subtype). The Mongoose library supports UUID fields directly. UUID v7 is preferred for MongoDB as it provides time-ordered IDs without relying on ObjectID.
Frequently Asked Questions
What does UUID stand for?
UUID stands for Universally Unique Identifier. It is a 128-bit number used to uniquely identify information in computer systems, standardized by RFC 4122 (and updated in RFC 9562 in 2024). The term GUID (Globally Unique Identifier) used by Microsoft refers to the same concept and format.
What is the difference between UUID and GUID?
None in practice. UUID is the IETF/ISO standard term; GUID is Microsoft's term for the same 128-bit identifier. Both follow the same format and generation rules. SQL Server uses GUID terminology (NEWID(), UNIQUEIDENTIFIER), while databases like PostgreSQL and MySQL use UUID terminology. The identifier itself is interchangeable.
What is UUID v4?
UUID v4 is the most common UUID version. It is generated from 122 random bits (6 bits are used for the version and variant markers). Because it is fully random, it is unpredictable and cannot be guessed or enumerated. The probability of collision between any two independently generated v4 UUIDs is negligible — approximately 1 in 5.3 × 10³⁶.
What is UUID v7 and why is it better for databases?
UUID v7 (RFC 9562, 2024) encodes the current Unix timestamp in milliseconds in the first 48 bits, followed by random bits. This makes v7 UUIDs monotonically increasing over time — when sorted lexicographically, they sort by creation time. For databases using B-tree indexes (which all SQL databases use), time-ordered UUIDs dramatically reduce index fragmentation and improve write performance compared to random v4 UUIDs.
What is a UETR and how does it relate to UUID?
A UETR (Unique End-to-End Transaction Reference) is a UUID v4 used in SWIFT banking payments to uniquely identify each financial transaction across the entire payment chain. Introduced with the ISO 20022 payment standard, UETRs allow banks to track a payment from sender to recipient regardless of how many intermediary banks are involved. Every SWIFT payment must include a UETR, which is a standard UUID v4 — you can generate one using this tool.
How do I generate a UUID in Python?
Python includes UUID support in its standard library: import uuid; my_uuid = uuid.uuid4(); print(str(my_uuid)). For UUID v5 (deterministic, namespace-based): uuid.uuid5(uuid.NAMESPACE_DNS, 'yourname'). No pip install needed.
How do I generate a UUID in JavaScript or Node.js?
In modern browsers and Node.js 14.17+: crypto.randomUUID() — no library needed. In older Node.js versions or for v5 support, use the uuid npm package: npm install uuid then import { v4 } from 'uuid'; v4();.
How do I generate a GUID in C#?
Guid.NewGuid() generates a new random GUID. To get it as a string: Guid.NewGuid().ToString() (lowercase with hyphens), .ToString("N") (no hyphens), .ToString("B") (with braces), or .ToString("D").ToUpper() (uppercase with hyphens).
How do I generate a GUID in SQL Server?
Use NEWID() for a random GUID: SELECT NEWID(). For a column default: id UNIQUEIDENTIFIER DEFAULT NEWID(). For sequential (time-ordered) GUIDs that avoid index fragmentation, use NEWSEQUENTIALID() as a column default (cannot be called in a SELECT, only as a default).
How do I validate a UUID online?
Use the validator section above — paste your UUID and it instantly checks whether it matches the standard UUID format and identifies the version. A valid UUID matches the pattern xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx where M is the version digit (1–8) and N is the variant digit (8, 9, a, or b).
Can I use UUIDs as database primary keys?
Yes, and it is common in distributed systems. UUIDs allow records to be created across multiple servers without a central ID authority. The main trade-off is size (16 bytes vs 4–8 bytes for an integer) and for random v4 UUIDs, index fragmentation. UUID v7 solves the fragmentation problem by being time-ordered. For new projects with distributed writes or microservices, UUID v7 primary keys are an excellent choice.
What is a nil UUID?
The nil UUID is a special-case UUID where all 128 bits are zero: 00000000-0000-0000-0000-000000000000. It is used as a placeholder or default value to indicate the absence of a real UUID, similar to how null is used for missing values.