Starting points for your own code. Run them in the environment shown below.
Node.js 22+ · ES module (.mjs)
Current inputs apply only to fields used by the example. Selected files are not embedded.
Install dependencies
npm install uuid
import { v4, v7, validate, version } from "uuid";
const ids = [v4(), v7()];
for (const id of ids) {
console.log({ id, valid: validate(id), version: version(id) });
}
Put it to work
Choose v4 for random identifiers, or v7 for time-ordered identifiers.
Details that matter
Format and meaning
v7 contains creation-time information. Do not use identifiers as secret authentication tokens.
Using it correctly
Validation checks UUID syntax and version, not whether a record exists in a database.
Supported scope and limits
Generate or validate up to 1,000 UUIDs
Split inputs that exceed the limit. If a format or algorithm is unsupported, choose a tool that matches your requirements instead of silently changing the format.