UUID v4 Generator

Instantly generate one or many cryptographically random UUIDs locally in your browser. Values follow RFC 9562 UUID v4, formerly specified by RFC 4122.

Your UUID v4

Generated privately on this device. Advanced format and batch controls are below.

Advertisement

Batch and format options

Enter a whole number from 1 to 10,000.

UUID representation

Case, hyphens, braces, URN, quotes, prefix, and suffix change each displayed and exported value. JSON always uses valid JSON string quoting. A prefix or suffix wraps the identifier, so the result is no longer a canonical UUID.

Batch output

Press Ctrl/Cmd + Enter to regenerate with the current settings. Large output is kept in this scrollable field for responsive rendering.

Validate and decode a UUID

Paste a canonical, braced, compact, or urn:uuid: value. Wrapping prefixes or suffixes are not part of a UUID and are not accepted.

Validation runs locally as you type.

Enter a UUID to see its version, variant, and canonical form.

How UUID v4 works

A UUID is a 128-bit identifier. Under RFC 9562 §5.4, UUID v4 contains 122 random bits: random_a, random_b, and random_c. The remaining six bits identify version 4 and the RFC UUID variant. RFC 9562 superseded RFC 4122.

random_a 48 random bits version 4 bits = 0100 random_b 12 random bits variant 2 bits = 10 random_c 62 random bits

The canonical pattern is xxxxxxxx-xxxx-4xxx-Nxxx-xxxxxxxxxxxx, where N is 8, 9, a, or b. The hyphens are display separators, not old-style time, clock, or node data. UUID v4 embeds neither a timestamp nor a MAC address.

Local randomness and security

This page feature-detects crypto.randomUUID() and validates its result. If unavailable, it uses crypto.getRandomValues(), then sets and validates the v4 version and variant bits. If neither secure API is available, the tool shows an error and does not generate values. Nothing is uploaded.

Cryptographically strong randomness makes v4 useful for opaque distributed IDs, but a UUID should not automatically replace a purpose-built API key, password-reset token, session secret, or authorization credential. Adding a prefix or suffix creates a wrapped identifier rather than a canonical UUID.

Last reviewed: .

UUID v4 collision probability

With 2122 possible random values, the birthday-bound approximation for small probabilities is p ≈ n(n−1) / (2 × 2122). Near 50%, use p ≈ 1 − exp(−n(n−1)/(2 × 2122)).

UUIDs generatedApproximate collision probability
1 million (106)9.4 × 10−26
1 billion (109)9.4 × 10−20
1 trillion (1012)9.4 × 10−14
About 2.71 × 101850%

At one million UUIDs per second, reaching the 50% threshold would take roughly 85,700 years. Actual collision risk also depends on a correctly implemented random source.

UUID v4 vs UUID v7

ConsiderationUUID v4UUID v7
Core dataRandomUnix timestamp plus random data
Chronological sortingNoYes
Creation-time privacyDoes not reveal timeReveals approximate creation time
Distributed generationExcellentExcellent with a correct implementation
B-tree index localityRandom inserts can fragment indexesTime ordering usually improves locality

Choose v4 for opaque distributed identifiers. In write-heavy databases, v7 can be preferable because chronologically ordered inserts reduce B-tree fragmentation. “GUID” is common Microsoft terminology, not a fundamentally different kind of identifier; in most modern contexts it refers to the same 128-bit UUID format.

Generate UUID v4 in code

Browser JavaScript

const id = crypto.randomUUID();

Node.js

const { randomUUID } = require('node:crypto');
const id = randomUUID();

Python

import uuid
id = uuid.uuid4()

Java

import java.util.UUID;
UUID id = UUID.randomUUID();

C#

using System;
Guid id = Guid.NewGuid();

Go (google/uuid)

import "github.com/google/uuid"
id := uuid.NewString()

PostgreSQL

SELECT gen_random_uuid();

MySQL: its built-in UUID() function does not guarantee UUID v4. Generate v4 in application code or use a carefully reviewed database-side implementation.

UUID v4 FAQ

Can UUID v4 values collide?

Yes in theory, but the 122 random bits make a collision extraordinarily unlikely. About 2.71 × 10¹⁸ generated UUID v4 values are needed for a 50% collision probability.

Does UUID v4 contain a timestamp or MAC address?

No. UUID v4 contains random data plus fixed version and variant bits; it does not encode a timestamp or MAC address.

Are GUID and UUID the same?

GUID is common Microsoft terminology for this family of 128-bit identifiers. In most modern developer contexts, GUID and UUID refer to the same textual identifier format.

Is UUID v4 suitable for database keys?

Yes, especially for opaque distributed IDs. Random v4 inserts can fragment B-tree indexes in write-heavy databases, so UUID v7 may offer better index locality.

How do I validate a UUID?

Normalize an optional urn:uuid: prefix, braces, and compact form, then verify 32 hexadecimal digits. For UUID v4, the version nibble must be 4 and the variant nibble must be 8, 9, a, or b.

Which characters can the UUID variant position contain?

For the RFC 9562 UUID variant, the first character of the fourth group is 8, 9, a, or b (case-insensitive).

Is UUID generation on this page private?

Yes. Generation and validation run locally in your browser using Web Crypto; values are not sent to this site.

When should I choose UUID v7 instead of v4?

Choose v7 when chronological sorting and database index locality matter. Choose v4 when you want a fully random, opaque identifier with no embedded creation time.

Explore more tools