CoShareX Logo
HomeBlogUtilitiesHow to Generate and Use UUID v4 in Web Applications
Utilities

How to Generate and Use UUID v4 in Web Applications

Published 2026-08-20
4 min read
By CoShareX

A Universally Unique Identifier (UUID) is a 128-bit label used for information in computer systems. Version 4 UUIDs are generated using random numbers.

Structure of a UUID v4

A standard UUID v4 contains 36 characters including 4 hyphens:

xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx

  • The 4 indicates version 4 (randomly generated).
  • The y is always one of 8, 9, a, or b per RFC 4122.
Featured Tool

UUID Generator

Generate cryptographically secure UUID (GUID) v4 strings online. Bulk generate unique identifiers with uppercase, lowercase, and hyphen options.

Generating UUID v4 in the Browser

Modern JavaScript runtimes support generating UUIDs natively using the crypto global:

javascript
1
2
const uuid = crypto.randomUUID();
console.log(uuid); // -> "e8555e5c-74a4-47c3-bb0d-f0bb50d6063b"

This uses a cryptographically secure random number generator (CSPRNG), ensuring collision probability is virtually zero.