UUID Generator

Generate UUIDs (Universally Unique Identifiers)


1. What is a UUID?

A UUID (Universally Unique Identifier) is a 128-bit number used to uniquely identify information. They are commonly used in distributed systems and databases.

2. How does it work?

UUID v4 (Random)

Version 4 UUIDs are randomly generated. The probability of generating duplicate UUIDs is extremely low - approximately 1 in 5.3×10³⁶ (5.3 undecillion).

Format

UUIDs are typically displayed as 32 hexadecimal digits, displayed in 5 groups separated by hyphens: xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx

3. Examples

Example UUID v4

550e8400-e29b-41d4-a716-446655440000

Another example

6ba7b810-9dad-11d1-80b4-00c04fd430c8

4. Source Code

typescript
1// npm install uuid
2// npm install @types/uuid --save-dev
3
4import { v4 as uuidv4, v1 as uuidv1, v5 as uuidv5, validate, version } from 'uuid';
5
6// Generate UUID v4 (random)
7function generateUUIDv4(): string {
8  return uuidv4();
9}
10