Skip to content
WebTricks

UUID generator

Generate one or many random v4 UUIDs with a click, using the browser crypto API. Copy individually or all at once.

10b84936b-fc81-4de6-b5c8-57f0d32202b0
23abd4dd5-b6e9-48b8-b42c-fc88f18cf32e
30de52c9f-628b-4fbb-a979-7a7bf2c9c519
4faf9a9c5-0699-425e-a4d6-bccb49e8fa3c
5190fe92d-6e08-48d4-b72b-fd09be8d6050

What this UUID generator does

Click once and get up to 100 fresh version 4 UUIDs, each produced by the browser’s crypto.randomUUID(). They are lowercase, hyphenated, 36 characters long and ready to paste into a database seed, a test fixture, a config file or an API request. Every ID can be copied on its own, or the whole list can be copied newline-separated. Generation is instant and local.

How to use it

  1. Set Count (1–100; the page starts with 5).
  2. Click Generate. Each click replaces the list with new values.
  3. Click Copy next to a single ID, or Copy all to grab the list, one UUID per line.

The input is clamped: 0 or a negative number produces one UUID, anything above 100 produces 100.

Anatomy of a v4 UUID

f47ac10b-58cc-4372-a567-0e02b2c3d479
│        │    │    │    └─ 12 hex (48 bits) random
│        │    │    └─ variant: first digit is 8, 9, a or b
│        │    └─ version: always 4 here
│        └─ 4 hex (16 bits) random
└─ 8 hex (32 bits) random

The groups are 8-4-4-4-12 hex digits = 32 hex digits = 128 bits, with 4 hyphens making 36 characters. Only two positions are fixed (the version nibble and the variant bits), which is how a regex like ^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$ can validate a v4 UUID. The all-zero 00000000-0000-0000-0000-000000000000 is the “nil” UUID and is never produced by a generator.

UUID versions compared

VersionBuilt fromSortable by timeLeaksWhen to prefer it
v160-bit timestamp + clock sequence + MAC addressRoughly (byte order is awkward)MAC address and creation timeLegacy systems only
v4122 random bitsNoNothingTokens, tests, keys where order does not matter
v5SHA-1 of a namespace + nameNoNothing (deterministic)Stable IDs derived from a URL or name
v748-bit Unix millisecond timestamp + 74 random bitsYes, lexically and in binaryCreation timeDatabase primary keys, event logs, anything indexed

This tool generates v4 only. If you need v7 in code, the uuid npm package (uuidv7()), PostgreSQL 18’s uuidv7() and many ORMs provide it.

UUIDs as database keys

A random v4 key is fine until the table is large enough that the index no longer fits in memory. Because each new key is uniformly random, inserts touch random index pages, causing page splits and cache misses; v7 keys are monotonically increasing so inserts append. Practical rules:

  • Store as 16 bytes, not 36 characters. Postgres has a native uuid type; MySQL and SQL Server use BINARY(16) / UNIQUEIDENTIFIER. Text storage more than doubles index size.
  • Do not strip the hyphens in APIs and logs; every parser expects them, and the compact 32-char form is a different representation.
  • Use v4 when the ID is public and creation time is sensitive (invite links, unsubscribe tokens). v7 reveals when the row was created, down to the millisecond.
  • Do not use a UUID as a secret on its own for anything long-lived — it is unguessable, but it is not a replacement for authentication.

Generating UUIDs in code

const id = crypto.randomUUID(); // browser (secure context) and Node 19+

In Node 14–18 use import { randomUUID } from 'node:crypto'. On the command line, uuidgen (macOS, Linux) or PowerShell’s [guid]::NewGuid() produce v4 values; Linux also exposes /proc/sys/kernel/random/uuid.

FAQ

Are these UUIDs cryptographically random?

Yes. They come from crypto.randomUUID(), which draws from the operating system's CSPRNG — the same source used for session tokens and keys, not Math.random().

What is a version 4 UUID?

A 128-bit identifier with 122 random bits; the remaining 6 bits mark the version (the 4 at the start of the third group) and the variant (8, 9, a or b at the start of the fourth group). It is defined in RFC 9562, which replaced RFC 4122.

How likely is a collision?

With 122 random bits you would need to generate about 2.7 quintillion UUIDs to reach a 50% chance of a single duplicate. For any practical system, treat v4 UUIDs as unique without coordination.

Is a GUID the same as a UUID?

Yes. GUID is Microsoft's name for the same 128-bit format. .NET's Guid.NewGuid() produces v4 values; the only cosmetic difference is that some Windows tools print them in uppercase or wrapped in braces.

Should I use UUID v4 or v7 for database primary keys?

v7 if your database supports it: its first 48 bits are a millisecond timestamp, so new rows land at the end of a B-tree index and inserts stay fast. Random v4 keys scatter across the index and cause page splits at scale. v4 is still fine for small tables, tokens, and anywhere you do not want to leak creation time.

Why does crypto.randomUUID not exist in my code?

It requires a secure context — HTTPS or localhost — and is not available on plain http:// pages. It shipped in Chrome 92, Firefox 95, Safari 15.4 and Node 19 (Node 14.17+ via require('crypto')).