UUID Generator
Generate one or many RFC 4122 version 4 UUIDs using the browser's cryptographic random source.
About UUID v4
A UUID — Universally Unique Identifier, also called GUID on Microsoft platforms — is a 128-bit value used as an identifier in distributed systems where coordination would be too expensive. The format is standardised by RFC 4122 and renders as 32 hexadecimal digits in the canonical form 8-4-4-4-12 separated by hyphens, for example 550e8400-e29b-41d4-a716-446655440000.
Version 4 UUIDs are generated almost entirely from random bytes. Six bits are reserved to declare the version (4) and the variant (RFC 4122), leaving 122 bits of randomness — enough that the probability of collision is negligible until you have generated about 2.71 quintillion of them. This generator uses crypto.randomUUID(), which delegates to the operating system's CSPRNG, so the values are suitable for security-sensitive use cases such as session tokens or one-time links.
Use cases
- Create primary keys for database rows when you need to generate the ID before inserting.
- Tag log lines or trace spans so you can correlate events across services.
- Generate idempotency keys for non-idempotent HTTP requests.
- Build invitation links or reset tokens that should be unguessable.
- Assign stable IDs to React list items that have no natural primary key.
Best practices
- Store UUIDs as 16-byte BINARY in MySQL or as the native UUID type in PostgreSQL — not as 36-character VARCHAR — to save space.
- Use UUIDv7 (time-ordered) when you need both uniqueness and good database index locality.
- Avoid embedding sensitive information in a UUID; treat it as opaque.
- Do not use UUIDs as a substitute for proper authorisation — knowing an ID is not the same as being allowed to access the resource.