DevOnlineTools

UUID Generator

Generate universally unique identifiers (UUIDs) in multiple versions. UUID v4 uses random generation, v1 is time-based, v5 uses a namespace and name, and the new v7 combines time-based monotonicity with randomness for database-friendly sorting.

devonlinetools://generators/uuid-generator
⌘ + EnterRun / Format
Shortcuts Active
f6809825-6ff9-47e3-b693-9b04be2fee21

Code Snippets & Examples

Copy-paste ready code implementations for your project:

JavaScript / Node.js 19+
// Built-in Web Crypto API
const uuid = crypto.randomUUID();
console.log(uuid);
Python 3
import uuid

# Generate a random UUID4
my_uuid = str(uuid.uuid4())
print(my_uuid)
Go
package main

import (
    "fmt"
    "github.com/google/uuid"
)

func main() {
    id := uuid.New().String()
    fmt.Println(id)
}
Bash CLI
# Linux / macOS CLI
uuidgen

Frequently Asked Questions

What is a UUID?

A UUID (Universally Unique Identifier) is a 128-bit identifier that is unique across all time and space. It is standardized in RFC 4122 and formatted as 8-4-4-4-12 hex digits, e.g., 550e8400-e29b-41d4-a716-446655440000.

What is the difference between UUID v4 and UUID v7?

UUID v4 is completely random and has no ordering. UUID v7 embeds a millisecond timestamp in the first 48 bits, making it sortable by creation time — ideal for database primary keys. UUID v7 was standardized in RFC 9562 (2024).

Are UUIDs truly unique?

Statistically, yes. UUID v4 has 122 bits of randomness. The probability of generating two identical UUIDs is astronomically low — roughly 1 in 5.3 × 10^36.

Should I use UUID or ULID for my database?

For modern databases, UUID v7 or ULID are preferred over v4 because they are time-sortable, which improves index performance. UUID v4's random nature causes index fragmentation in B-tree indexes.