uuid (npm)
RFC 4122 compliant UUID generation for JavaScript and Node.js. Supports UUIDv1 (time-based), UUIDv3 (namespace MD5), UUIDv4 (random), UUIDv5 (namespace SHA1), and UUIDv7 (time-ordered random, new in v10). UUIDv7 is increasingly preferred over v4 for database primary keys as it's sortable by creation time. The standard UUID library for JavaScript.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Uses Web Crypto API (CSPRNG) for randomness — cryptographically secure. UUIDv1 MAC address disclosure is a minor privacy concern. Zero third-party dependencies.
⚡ Reliability
Best When
You need RFC-compliant UUID generation in JavaScript/TypeScript with well-defined version semantics and broad ecosystem compatibility.
Avoid When
You need short, URL-friendly IDs — nanoid generates shorter random IDs. For time-ordered sortable IDs with less overhead, consider ULID.
Use Cases
- • Generate unique IDs for agent session tracking, request correlation, and workflow execution identifiers with UUIDv4
- • Create sortable primary keys for agent event logs and database records using UUIDv7 — time-ordered UUIDs avoid index fragmentation
- • Produce deterministic UUIDs from namespace + name pairs using UUIDv5 for stable IDs based on content hashing (URL normalization, deduplication)
- • Correlate distributed agent traces and logs using UUID request IDs that are passed across service boundaries
- • Generate browser-compatible UUIDs using the Web Crypto API-based uuid implementation that works in both Node.js and browsers
Not For
- • Short human-readable IDs — UUIDs are 36 characters; use nanoid or cuid2 for compact, URL-safe unique IDs
- • Sequential database IDs with minimal storage overhead — use database auto-increment or ULID for smaller, sequential IDs
- • Random string generation beyond ID purposes — use crypto.randomBytes() directly for arbitrary random data generation
Interface
Authentication
No authentication — local ID generation library.
Pricing
uuid npm package is open source and free.
Agent Metadata
Known Gotchas
- ⚠ uuid v7+ is ESM-only for the main package — require('uuid') works but import { v7 } from 'uuid' requires proper ESM bundler setup; check bundler config
- ⚠ UUIDv1 encodes the MAC address of the generating machine — privacy concern for agents that distribute UUIDv1 IDs externally; prefer v4 or v7
- ⚠ UUIDv7 was added in uuid 9.0+ — verify your version has v7 support before using; older codebases may be on uuid 3.x or 7.x without v7
- ⚠ crypto.randomUUID() in Node.js 14.17+ generates UUIDv4 natively without the uuid package — no dependency needed for basic v4 generation
- ⚠ uuid parse() returns a Uint8Array, not a string — use uuid.stringify() to convert back; forgetting this causes subtle bugs when comparing UUIDs
- ⚠ UUID string comparison is case-sensitive in some implementations — normalize to lowercase with .toLowerCase() before comparing UUID strings
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for uuid (npm).
Scores are editorial opinions as of 2026-03-06.