Home / UUID Generator / JavaScript

UUID Generator for JavaScript

Generate a UUID right here, or copy the exact JavaScript code. Native crypto.randomUUID() works in both Node.js and the browser, no npm package required.

100% client-side No account, no sign-up Native crypto.randomUUID(), no npm package needed

UUID Generator for JavaScript

Click Generate to create one.

Generate a UUID in JavaScript

Modern Node.js (14.17+) and every current browser support crypto.randomUUID() natively, the same method this page’s own generator uses. No uuid npm package needed unless you’re targeting older environments.

// Node.js or browser (no import needed, crypto is global)
const id = crypto.randomUUID();
console.log(id);
// e.g. 550e8400-e29b-41d4-a716-446655440000

// Older Node.js versions:
const { randomUUID } = require('crypto');
console.log(randomUUID());

For older browsers without native support, or for UUID versions other than v4, the uuid npm package remains the standard fallback.

How this tool works

crypto.randomUUID() is defined by the Web Crypto API specification to generate a version-4 UUID using a cryptographically secure random number generator, the exact same method this page’s own generator tool calls.

Sources:

Frequently asked questions

Do I need to install the uuid npm package?

Not for basic v4 UUIDs on modern Node.js (14.17+) or any current browser. crypto.randomUUID() is built in. The uuid package is still useful for older environments or UUID versions it doesn’t natively support.

Does crypto.randomUUID() work in the browser and Node.js the same way?

Yes. It’s the same Web Crypto API method in both environments, and produces identical version-4 UUID output.