UUID Generator

Generate and validate UUIDs (v1, v4, v5, v7) with batch support, multiple formatting options, and multilingual code examples.

UUID Generator

Formatting Options

UUID Validator

How to Use

A UUID is a 128-bit identifier, conventionally represented as 36 characters including hyphens.
UUID v1: Based on timestamp and MAC address — time-ordered but may leak timing or location data.
UUID v4: Randomly generated — most common, offering strong uniqueness and privacy.
UUID v7: Based on Unix milliseconds + randomness — naturally sortable and avoids v1’s privacy issues.
UUID v5: Derived from a namespace UUID and name via SHA-1 — identical inputs always produce the same output.
Standard format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (36 characters).

Features

  • Supports UUID v1, v4, v5, and v7
  • Batch generation with custom count
  • Flexible formatting: uppercase, no hyphens, braces
  • Built-in validator with version detection
  • Full internationalisation and multi-theme support

What is a UUID?

A UUID is a 128-bit identifier, conventionally represented as 36 characters including hyphens.

UUID v1: Based on timestamp and MAC address — time-ordered but may leak timing or location data.

UUID v4: Randomly generated — most common, offering strong uniqueness and privacy.

UUID v7: Based on Unix milliseconds + randomness — naturally sortable and avoids v1’s privacy issues.

UUID v5: Derived from a namespace UUID and name via SHA-1 — identical inputs always produce the same output.

UUID Quick Examples

Standard format:
550e8400-e29b-41d4-a716-446655440000
Uppercase format:
550E8400-E29B-41D4-A716-446655440000
No hyphens:
550e8400e29b41d4a716446655440000
With braces:
{550e8400-e29b-41d4-a716-446655440000}

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 — use v4 if privacy matters.
  • Case sensitivity: UUID matching is case-insensitive.
  • Hyphens are purely for readability — keep them unless required otherwise.
  • Braced format (e.g., {xxxxxxxx-...}) is accepted in some contexts (e.g., Windows Registry).
  • v5 is deterministic (same namespace + name = same UUID). Ideal for idempotent scenarios — avoid where unpredictability is needed.

Using UUIDs in Programming Languages

JavaScript
Generate
// 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 Time + Random)
// 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();
Validate
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
Generate
<?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();
UUID v7 (Unix Time + Random)
<?php
// composer require ramsey/uuid:^4.7
use Ramsey\Uuid\Uuid;

$uuid7 = Uuid::uuid7();
Validate
<?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
Python
Generate
import uuid
# v4
uid = uuid.uuid4()
# v1
uid1 = uuid.uuid1()
UUID v7 (Unix Time + Random)
# pip install uuid6
from uuid6 import uuid7

uid7 = uuid7()
Validate
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
Generate
// go get github.com/google/uuid
import "github.com/google/uuid"

id := uuid.New()     // v4
id1 := uuid.NewUUID() // v1 (may return error)
UUID v7 (Unix Time + Random)
// go get github.com/gofrs/uuid/v5
import (
  uuid "github.com/gofrs/uuid/v5"
)

id7, err := uuid.NewV7()
Validate
import "github.com/google/uuid"
_, err := uuid.Parse(id.String()) // err == nil means valid
Rust
Generate
// 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
UUID v7 (Unix Time + Random)
// Cargo.toml: uuid = { version = "1", features = ["v7"] }
use uuid::Uuid;

let v7 = Uuid::now_v7();
Validate
use uuid::Uuid;
let ok = Uuid::parse_str(v4.to_string().as_str()).is_ok();
Java
Generate
import java.util.UUID;

UUID id = UUID.randomUUID(); // v4
UUID v7 (Unix Time + Random)
// Maven: com.github.f4b6a3:uuid-creator
import com.github.f4b6a3.uuid.UuidCreator;

UUID v7 = UuidCreator.getTimeOrderedEpoch(); // UUIDv7
Validate
import java.util.UUID;

try { UUID.fromString(id.toString()); /* valid */ } catch (IllegalArgumentException ex) { /* invalid */ }