uuid
RFC4122 UUID generation for JavaScript — create v1, v3, v4, v5, and v7 UUIDs for entity identification and distributed systems.
uuid
General JSRFC4122 UUID generation for JavaScript — create v1, v3, v4, v5, and v7 UUIDs for entity identification and distributed systems.
Fit
Bundle (gzip)
3.8 kB
10.0 kB raw
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Generating universally unique identifiers for database records, distributed events, and API resources requires RFC4122 compliance. Rolling your own UUID implementation risks subtle entropy or formatting bugs.
What It Does
The uuid package generates all major UUID versions: v4 (random, most common), v7 (time-ordered for database index performance), v1 (time-based), v3/v5 (namespace-based, deterministic). All output is formatted as the canonical xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx string.
Installation
npm install uuidUsage Example
import { v4 as uuidv4, v7 as uuidv7, validate, version } from 'uuid';
// Random UUID (most common)
const id = uuidv4(); // '9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d'
// Time-ordered UUID (better for database indexes)
const orderedId = uuidv7(); // '018e3c1a-7f2a-7a8b-8b2c-4b5d6e7f8a9b'
// Validate
validate('not-a-uuid'); // false
validate(id); // true
version(id); // 4Related packages
Unified TypeScript SDK for building AI-powered apps — switch between 20+ LLM providers without rewriting code.
animejsGeneral JSLightweight JavaScript animation library with a tiny footprint and a powerful, expressive API.
AOSGeneral JSAn easy-to-use library that makes elements fade, slide, or zoom into view as the user scrolls down your page.
archiverGeneral JSStreaming interface for generating ZIP and TAR archives in Node.js — create compressed archives programmatically from files, directories, and buffers.
@formkit/auto-animateGeneral JS> Add smooth transitions to any element with a single line — zero-config animations for adds, removes, and moves.