UUID Generator
A professional UUID generation and validation tool that supports multiple UUID versions including v1 (timestamp), v4 (random), v5 (name-based), and v7 (Unix time + random). Offers batch generation with customizable count, flexible formatting options including uppercase conversion, hyphen removal, and brace addition. Includes a built-in UUID validator with version detection and provides multi-language code examples. Suitable for database record identification, log tracing, cross-system interfaces, and other scenarios. All operations are performed locally in your browser, ensuring privacy and security.
Usage Guide
Features
- Supports UUID v1, v4, v5, and v7
- Batch generation with customizable count
- Flexible formatting: uppercase, remove hyphens, add braces
- Built-in validator with automatic version detection
- Full internationalization and multi-theme support
What is a UUID?
UUIDs are 128-bit identifiers, commonly represented as 36-character strings with hyphens.
UUID v1: Based on timestamp and MAC address; time-ordered but may leak timing or location information.
UUID v4: Randomly generated; most widely used, offering strong uniqueness and privacy.
UUID v7: Based on Unix milliseconds + random bits; naturally sortable and avoids the privacy issues of v1.
UUID v5: Deterministically generated from a namespace UUID and name using SHA-1; identical inputs always produce the same output.
UUID Common Use Cases
- Unique identifiers for database records or resources
- Trace IDs for logging and event tracing
- Unpredictable public identifiers
- Consistent identifiers across system integrations
UUID FAQs & Pitfalls
- v1 and Privacy: v1 can expose timestamps or hardware locations; prefer v4 for privacy-sensitive use cases.
- Case sensitivity: UUID matching is case-insensitive.
- Hyphens are purely for readability; keep them unless constrained by legacy systems.
- Braced format (e.g., {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}) is accepted in some environments (e.g., Windows Registry).
- v5 is deterministic: same namespace + name => same UUID. Ideal for idempotent operations; avoid when unpredictability is required.
How to Use UUIDs in Programming Languages
// UUID v4 (simple)
function uuidv4(){
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
const r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8);
return v.toString(16);
});
}
const id = uuidv4();
// UUID v7 (Unix ms + randomness)
function uuidv7(){
const cryptoObj = (globalThis.crypto || globalThis.msCrypto);
const rb = n => { const a = new Uint8Array(n); cryptoObj?.getRandomValues ? cryptoObj.getRandomValues(a) : a.forEach((_,i)=>a[i]=Math.random()*256|0); return a; };
const hex = b => Array.from(b).map(x=>x.toString(16).padStart(2,'0')).join('');
const ts = BigInt(Date.now()).toString(16).padStart(12,'0');
const ver = rb(2); ver[0] = (ver[0] & 0x0f) | 0x70; // set version 7
const vrn = rb(2); vrn[0] = (vrn[0] & 0x3f) | 0x80; // RFC4122 variant
const tail = rb(6);
return `${ts.slice(0,8)}-${ts.slice(8,12)}-${hex(ver)}-${hex(vrn)}-${hex(tail)}`;
}
const id7 = uuidv7();
const re=/^[0-9a-f]{8}-[0-9a-f]{4}-[1-57][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
re.test(id); // true/false
<?php
// v4 using random_bytes
function uuidv4(){
$data = random_bytes(16);
$data[6] = chr((ord($data[6]) & 0x0f) | 0x40);
$data[8] = chr((ord($data[8]) & 0x3f) | 0x80);
return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4));
}
$id = uuidv4();
<?php
// composer require ramsey/uuid:^4.7
use Ramsey\Uuid\Uuid;
$uuid7 = Uuid::uuid7();
<?php
$re = '/^[0-9a-f]{8}-[0-9a-f]{4}-[1-57][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i';
preg_match($re, $id) === 1; // true/false
import uuid
# v4
uid = uuid.uuid4()
# v1
uid1 = uuid.uuid1()
# pip install uuid6
from uuid6 import uuid7
uid7 = uuid7()
import re
re_uuid = re.compile(r'^[0-9a-f]{8}-[0-9a-f]{4}-[1-57][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$', re.I)
bool(re_uuid.match(str(uid)))
// go get github.com/google/uuid
import "github.com/google/uuid"
id := uuid.New() // v4
id1 := uuid.NewUUID() // v1 (may return error)
// go get github.com/gofrs/uuid/v5
import (
uuid "github.com/gofrs/uuid/v5"
)
id7, err := uuid.NewV7()
import "github.com/google/uuid"
_, err := uuid.Parse(id.String()) // err == nil means valid
// Cargo.toml: uuid = { version = "1", features = ["v4", "v1"] }
use uuid::Uuid;
let v4 = Uuid::new_v4();
// v1 requires a context/ts, often via external crate; shown for completeness
// Cargo.toml: uuid = { version = "1", features = ["v7"] }
use uuid::Uuid;
let v7 = Uuid::now_v7();
use uuid::Uuid;
let ok = Uuid::parse_str(v4.to_string().as_str()).is_ok();
import java.util.UUID;
UUID id = UUID.randomUUID(); // v4
// Maven: com.github.f4b6a3:uuid-creator
import com.github.f4b6a3.uuid.UuidCreator;
UUID v7 = UuidCreator.getTimeOrderedEpoch(); // UUIDv7
import java.util.UUID;
try { UUID.fromString(id.toString()); /* valid */ } catch (IllegalArgumentException ex) { /* invalid */ }