A UUID (Universally Unique Identifier) is a 128-bit (16-byte) identifier that's considered unique for practical purposes even when generated without a central authority. In standard text form it's written as 32 hexadecimal characters and 4 hyphens, grouped 8-4-4-4-12 (e.g. 550e8400-e29b-41d4-a716-446655440000). This tool can generate every version defined by RFC 4122 and the current RFC 9562 — v1, v3, v4, v5, and v7.
What is a UUID, and what are its versions?
A complete explanation of RFC 4122/9562 UUID versions, when to use each one, and how a GUID differs.
Extra mini tools: NIL UUID, ULID & Base64 converter
Three extra mini tools inspired by competitor UUID tools: a fixed empty UUID, a sortable ULID identifier, and a UUID-to-Base64/Hex converter.
UUID versions & format reference tables
A citable version comparison, format examples, and a UUID/GUID/ULID comparison.
| Version | Source data | Sortable? | Typical use |
|---|---|---|---|
| v1 | Timestamp + node ID | Partially | Legacy systems, backward compatibility |
| v3 | Namespace + name (MD5) | No | Deterministic ID (legacy) |
| v4 | Fully random | No | General purpose, most common |
| v5 | Namespace + name (SHA-1) | No | Deterministic ID (recommended) |
| v7 | Timestamp + random | Yes | Database primary keys |
| ULID (extra) | Timestamp + random (Base32) | Yes | Sortable, short-string ID |
| Format | Example |
|---|---|
| Standard (lowercase) | 550e8400-e29b-41d4-a716-446655440000 |
| Uppercase | 550E8400-E29B-41D4-A716-446655440000 |
| No hyphens | 550e8400e29b41d4a716446655440000 |
| Braces (.NET GUID) | {550e8400-e29b-41d4-a716-446655440000} |
| URN prefix | urn:uuid:550e8400-e29b-41d4-a716-446655440000 |
| Base64 (16 bytes) | VQ6EAOKbQdSnFkRmVUQAAA== |
| Property | UUID | GUID | ULID |
|---|---|---|---|
| Bit length | 128 | 128 (same standard) | 128 |
| Text length | 36 characters | 36 (or 38 with braces) | 26 characters |
| Alphabet | Hex (0-9, a-f) + hyphens | Hex + hyphens | Crockford Base32 |
| Sorts in time order? | Only v1/v7 | Only v1/v7 | Yes (by default) |
| Common use | General purpose | .NET / Windows ecosystem | Database keys, log IDs |
Language-specific code examples: how to generate a UUID
Ready-to-copy UUID/GUID generation code for Python, JavaScript/Node, Java, C#, Go, PHP, PostgreSQL, and MySQL. Each shows that language's standard approach.
uuid module, no install needed.# Standard library, no install needed import uuid # v4 (random) — most common use print(uuid.uuid4()) # 550e8400-e29b-41d4-a716-446655440000 # v5 (name-based, SHA-1) — deterministic print(uuid.uuid5(uuid.NAMESPACE_DNS, "example.com")) # v1 (time + node) print(uuid.uuid1()) # Text formats u = uuid.uuid4() print(u.hex) # no hyphens print(str(u).upper()) # uppercase
crypto.randomUUID() in modern browsers and Node 19+.// Browser + Node 19+ (built-in, v4)
const id = crypto.randomUUID();
console.log(id); // 550e8400-e29b-41d4-a716-446655440000
// Node.js (via the crypto module)
import { randomUUID } from "node:crypto";
console.log(randomUUID());
// Uppercase / no hyphens
console.log(id.toUpperCase());
console.log(id.replace(/-/g, ""));
java.util.UUID class (v4 random and v3 name-based).import java.util.UUID;
// v4 (random)
UUID id = UUID.randomUUID();
System.out.println(id); // 550e8400-e29b-41d4-a716-446655440000
// v3 (name-based, MD5)
UUID named = UUID.nameUUIDFromBytes("example.com".getBytes());
System.out.println(named);
// Parse from text
UUID parsed = UUID.fromString("550e8400-e29b-41d4-a716-446655440000");
Guid struct. .NET 9 also adds time-ordered Guid.CreateVersion7().using System;
// v4-like GUID (random)
Guid id = Guid.NewGuid();
Console.WriteLine(id); // 550e8400-e29b-41d4-a716-446655440000
Console.WriteLine(id.ToString("B")); // {550e8400-...} .NET GUID format
Console.WriteLine(id.ToString("N")); // no hyphens
Console.WriteLine(id.ToString("D").ToUpper()); // uppercase
// .NET 9+: v7 (time-ordered, database-friendly)
Guid v7 = Guid.CreateVersion7();
github.com/google/uuid package (go get github.com/google/uuid).package main
import (
"fmt"
"github.com/google/uuid"
)
func main() {
fmt.Println(uuid.New()) // v4 (random)
// v5 (name-based, SHA-1)
fmt.Println(uuid.NewSHA1(uuid.NameSpaceDNS, []byte("example.com")))
// v7 (time-ordered) — google/uuid v1.6+
v7, _ := uuid.NewV7()
fmt.Println(v7)
}
ramsey/uuid package (composer require ramsey/uuid).use Ramsey\Uuid\Uuid; // v4 (random) echo Uuid::uuid4()->toString(); // 550e8400-e29b-41d4-a716-446655440000 // v7 (time-ordered, database-friendly) echo Uuid::uuid7()->toString(); // v5 (name-based, SHA-1) — deterministic echo Uuid::uuid5(Uuid::NAMESPACE_DNS, "example.com")->toString();
gen_random_uuid() is built in on 13+ (older versions need the pgcrypto extension).-- Generate a v4 (random) UUID SELECT gen_random_uuid(); -- Automatic default on a table column CREATE TABLE users ( id uuid PRIMARY KEY DEFAULT gen_random_uuid(), name text NOT NULL ); -- Older versions (PostgreSQL 12 and earlier): -- CREATE EXTENSION IF NOT EXISTS pgcrypto;
UUID() generates a v1-based value; UUID_TO_BIN(..., 1) is recommended for sorted storage.-- Generate a text UUID (v1-based) SELECT UUID(); -- Store as a sorted 16-byte BINARY (index-friendly) SELECT UUID_TO_BIN(UUID(), 1); CREATE TABLE users ( id BINARY(16) PRIMARY KEY, name VARCHAR(120) NOT NULL ); -- Convert back to text when reading: -- SELECT BIN_TO_UUID(id, 1) FROM users;
UUID terms glossary
Short definitions of the core concepts used when discussing UUIDs/GUIDs.
In-depth guides
Detailed answers to the most common UUID questions.
Which UUID version should I use?
For most scenarios, v4 (fully random) is a good default: it's simple, privacy-friendly, and leaks no information. If you'll use it as a database primary key and index performance matters, prefer v7; because sequentially generated v7 values sort in time order, they cause less B-tree index fragmentation.
If you need to always derive the same identifier from the same input (e.g. a URL or email address), use v5 (SHA-1-based); v3 (MD5-based) is kept only for legacy system compatibility. Reach for v1 only when working with older systems that require it for backward compatibility.
For a database primary key: UUID, auto-increment, or ULID?
Auto-incrementing integers index the fastest, but can collide in distributed systems (when multiple servers insert records simultaneously) and reveal the row count publicly. A v4 UUID never collides, but being fully random it can fragment B-tree indexes and slow down writes.
v7 UUID or ULID solves this with a timestamp prefix: neither collides, and because they're inserted in sequence their index performance is close to auto-increment. ULID is also shorter (26 characters vs. UUID's 36); the choice usually comes down to what your ecosystem (ORM/database) supports.
How low is the v4 UUID collision probability, really?
A v4 UUID has 122 randomly generated bits, giving 2122 (≈5.3 × 1036) possible values. Using the birthday-paradox calculation, you'd need to generate roughly 2.71 quintillion (2.71 × 1018) UUIDs before reaching a 50% chance of a collision — a practically impossible scale, equivalent to every person on Earth generating billions of UUIDs every second.
For this reason, v4 UUIDs are safely treated as "unique" in real-world applications. That said, the quality of the random number generator matters; this tool uses the cryptographic crypto.getRandomValues instead of the insecure Math.random().
Add this tool to your site (embed code)
Embed the UUID generator on your own website for free. Copy the code below into your HTML — the tool runs in a simplified view and links back to this page as its source.
The embedded tool has a fixed layout; you can adjust the height value to fit your site. No ads or personal data, runs entirely client-side.
Frequently asked questions
What is a UUID?
How is a v4 UUID generated?
What is the difference between a GUID and a UUID?
How do I generate UUIDs in bulk?
How many characters or bytes long is a UUID?
Is an online UUID generator safe to use?
What is the difference between UUID v1 and v4?
What is a ULID, and how does it differ from a UUID?
How can I find out when a v7 or v1 UUID was generated?
How do you generate a UUID in Python, C#, PostgreSQL, and similar languages?
uuid.uuid4(),
JavaScript/Node crypto.randomUUID(), Java UUID.randomUUID(), C#/.NET Guid.NewGuid(),
Go uuid.New(), PHP Uuid::uuid4(), PostgreSQL gen_random_uuid(), MySQL UUID().
Name-based (v5) and time-ordered (v7) examples are in the same section.Can I get the output as quoted, comma-separated, or URL-encoded UUIDs?
Methodology & sources
Sources: RFC 4122 (A Universally Unique IDentifier) · RFC 9562 (the current UUID standard, adding v6/v7/v8) · W3C Web Cryptography API · the official ULID specification (Crockford Base32). Last updated: July 19, 2026. Results are algorithmic; v3/v5 are deterministic, while v1/v4/v7 and ULID rely on cryptographic randomness.