🛠️
Utility70M+/wkMIT

uuid

uuid is the standard library for generating RFC 4122 compliant Universally Unique Identifiers (UUIDs) in JavaScript. The package supports multiple UUID versions

Installation

npm
npm install uuid
yarn
yarn add uuid
pnpm
pnpm add uuid

Import

ESM
import { v4 as uuidv4 } from 'uuid';

Quick Example

usage
import { v4 as uuidv4, v7 as uuidv7, validate } from 'uuid';

const id = uuidv4();
console.log(id); // '9b1deb4d-3b7d-4bad-...'

const sortableId = uuidv7();
console.log(validate(id)); // true

About uuid

uuid is the standard library for generating RFC 4122 compliant Universally Unique Identifiers (UUIDs) in JavaScript. The package supports multiple UUID versions: v1 (timestamp-based), v3 (namespace with MD5 hashing), v4 (random), v5 (namespace with SHA-1 hashing), v6 (reordered timestamp for better database indexing), and v7 (Unix timestamp-based for sortable IDs). UUID v4, which generates random identifiers, is the most commonly used version for generating unique identifiers for database records, session tokens, correlation IDs, and temporary file names. The library works in both Node.js and browser environments, using cryptographically strong random number generation when available. uuid provides validation and parsing functions for working with existing UUIDs and produces properly formatted 36-character strings (e.g., '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'). The library's deterministic v3 and v5 versions are useful when you need consistent UUIDs derived from a namespace and name combination. While crypto.randomUUID() is now available natively in modern runtimes, the uuid package provides broader version support, validation utilities, and compatibility with older environments.

Quick Facts

Packageuuid
CategoryUtility
Weekly Downloads70M+
LicenseMIT
Installnpm install uuid

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.