UUID in JavaScript
JavaScript UUID Generator
JavaScript has shipped UUID v4 in the platform since 2021, so a random identifier is one method call away — crypto.randomUUID().
Built into the browserNo dependencyv4 + v7
Generated locally with the Web Crypto API — nothing leaves your browser.
Generating UUIDs in JavaScript
crypto.randomUUID()is part of the Web Crypto API. It draws 122 random bits from the platform CSPRNG and returns the canonical 8-4-4-4-12 string, so the value is safe for tokens as well as for database keys. It is available in every current browser and in Node 19 and later.- What it does not give you is version 7. There is no
crypto.randomUUIDV7(): for time-ordered keys you add a package (uuid, oruuidv7) or generate the value here and paste it. Everything else — uppercase, hyphens, braces, batches — is a formatting decision you make at the edges.
How to generate
- Press Generate UUID above to mint a value in this browser — nothing is sent anywhere.
- Copy one value with Copy, or set How many and use Copy all for a fixture list.
- Switch Version if your code needs v7 instead of the v4 default, and turn on Formatting to match your stack's conventions.
Use Cases
- React and framework keys — a stable per-row identifier that survives reordering.
- Idempotency keys on outbound API calls, so a retry is recognised as the same request.
- Test fixtures — request a few dozen at once and paste them into a seed file.
How JavaScript UUID Generator Compares
| crypto.randomUUID() | Built in, v4 only, CSPRNG-backed |
| uuid (npm) | All versions including v7, ~3 kB |
| nanoid | Shorter and alphabet-configurable, not a UUID |
Code Examples
JavaScript
// Browser and Node 19+
const id = crypto.randomUUID();
// 'f81d4fae-7dec-41d0-a765-00a0c91e6bf6'
// A batch, for fixtures
const ids = Array.from({ length: 25 }, () => crypto.randomUUID());Older runtimes
// Node 16+/14.17, and for a v7 fallback
const { randomUUID, v7: uuidv7 } = require('crypto');
const { v7 } = require('uuid'); // npm install uuid
const v4 = randomUUID();
const timeOrdered = v7();Frequently Asked Questions
Is crypto.randomUUID() available in every browser?
Yes in every current browser (Chrome 92+, Firefox 95+, Safari 15.4+) and in Node 19+. On older runtimes the
uuid package is the drop-in replacement.Does crypto.randomUUID() generate version 4?
Always. The version and variant nibbles are fixed by the spec, and there is no built-in v7 — that needs the
uuid package or another generator.How do I get a UUID without hyphens in JavaScript?
crypto.randomUUID().replaceAll('-', '') gives the 32-character hex form. Switch Hyphens off above to produce the same shape from this page.Related tools
UUID v1 GeneratorUUID v3 GeneratorUUID v4 GeneratorUUID v5 GeneratorUUID v6 GeneratorUUID v7 GeneratorUUID v8 GeneratorBulk UUID GeneratorShort UUID GeneratorUUID ValidatorUUID FormatterJavaScript UUID GeneratorTypeScript UUID GeneratorNode.js UUID GeneratorReact UUID GeneratorPython UUID GeneratorJava UUID GeneratorC# UUID GeneratorGo UUID GeneratorPHP UUID GeneratorRuby UUID GeneratorRust UUID GeneratorKotlin UUID GeneratorSwift UUID GeneratorSQL UUID Generator