uuid
Robust RFC 4122-compliant UUID generation for JavaScript and TypeScript. Supports UUID v1 (timestamp-based), v3 (MD5 namespace), v4 (random), v5 (SHA-1 namespace), v6 (monotonic timestamp), and v7 (Unix-timestamp-sorted random). UUID v4 is the most common for general unique identifiers. UUID v7 is the emerging standard for database primary keys due to its time-sortable property. Works in Node.js and browsers with cryptographic randomness.
Score Breakdown
⚙ Agent Friendliness
🔒 Security
Pure utility library — no network, no secrets. Uses cryptographic randomness (crypto.getRandomValues) for v4/v7. Minimal attack surface.
⚡ Reliability
Best When
You need RFC 4122-compliant UUID generation in JavaScript/TypeScript for standard unique identifiers, database IDs, or distributed system correlation.
Avoid When
You need short URL-safe IDs (use nanoid) or already have crypto.randomUUID() available in your environment (Node.js 14.17+, browsers with crypto API).
Use Cases
- • Generate unique IDs for database records, distributed systems, or agent sessions using uuid.v4() for random UUIDs
- • Generate time-sortable UUID v7 for database primary keys that benefit from sequential ordering for index performance
- • Create deterministic UUIDs from a namespace and name using v5 for idempotent ID generation from content
- • Generate correlation IDs for distributed tracing in agent pipelines to track requests across services
- • Create unique IDs for file names, message IDs, or session tokens in web applications
Not For
- • Human-readable short IDs — use nanoid or cuid2 for shorter, URL-safe unique IDs
- • Sequential integer IDs — use database auto-increment or sequences for ordered IDs
- • Cryptographic tokens — use crypto.randomBytes() for security-sensitive tokens; UUID v4 is suitable but purpose-built token generation is preferred
Interface
Authentication
No authentication — pure utility library.
Pricing
Fully free, MIT licensed.
Agent Metadata
Known Gotchas
- ⚠ Node.js 14.17+ and modern browsers have crypto.randomUUID() built-in — for simple v4 UUID generation, the native API may remove the need for this dependency
- ⚠ UUID v4 is NOT time-sortable — for database primary keys that benefit from sequential ordering, use UUID v7 (uuid.v7()) or nanoid
- ⚠ UUID v7 requires uuid >= 9.0.0 — ensure correct package version when using v7; older uuid versions only have v1-v5
- ⚠ uuid.parse() returns Uint8Array (bytes), not string — use uuid.stringify() to convert back; some code paths need byte vs string format awareness
- ⚠ UUIDs are 36 chars with hyphens — if storing in database, use uuid_generate_v4() in PostgreSQL or UUID type for storage efficiency over varchar
- ⚠ Collision probability for v4: approximately 1 in 5 undecillion — practically impossible for any normal use case but not cryptographically secure for tokens
Alternatives
Full Evaluation Report
Detailed scoring breakdown, competitive positioning, security analysis, and improvement recommendations for uuid.
Scores are editorial opinions as of 2026-03-06.