Skip to content

uuid

Generates standard-format unique IDs (UUIDs) in JavaScript, for browsers, Node.js and React Native.

Stars
15.3k
Forks
999
Licence
MIT
Language
TypeScript
Last update
5 days ago
Type
Library

What it is

This is a JavaScript library that creates UUIDs, which are long random-looking identifiers used to tell records, requests or objects apart without a central counter. It follows the RFC 9562 standard (formerly RFC 4122) and supports multiple UUID versions, including random, timestamp-based, and name-based forms. It is installed from npm and works in TypeScript, modern browsers, Node.js and React Native.

  • Give each new database row or document a unique ID with uuidv4()
  • Create time-ordered IDs with v7() for sortable records
  • Generate stable IDs from a name and namespace with v5()
  • Check whether a string is a valid UUID with validate()

Great for

  • JavaScript or TypeScript developers who need standard-format IDs
  • Front-end projects that generate IDs in the browser
  • Node.js back-end code that needs unique identifiers
  • React Native or Expo apps

Not ideal for

  • Projects that need a database-generated ID sequence instead, since this only generates IDs in code
  • Anyone needing cryptographic key material; a UUID is an identifier, not a secret, and the README does not present it as one
  • Non-JavaScript projects, since the README describes only JavaScript usage
Step-by-step guide: how to use uuidInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js or a bundler that supports npm packages

    Install from npm

    npm install uuid
  2. 2

    Run it

    • Install the package with npm install uuid
    • Import the function you need, for example import { v4 as uuidv4 } from 'uuid'
    • Call uuidv4() to get a UUID string
  3. 3

    Get the most out of it

    • Use the options.random or options.rng fields to make output reproducible in tests
    • Pass a buffer and offset to v4() to write bytes into an existing array instead of creating strings
    • Use v1ToV6() or v6ToV1() to convert between timestamp formats
    • Use the uuid command line utility for generating IDs from a terminal

Downloads

Strengths

  • Supports all RFC 9562 UUID versions according to the README
  • Zero dependencies and tree-shakable, so it adds little to bundle size
  • Uses the modern crypto API for random values

Trade-offs

  • CommonJS is no longer supported starting with version 12, which may matter for older projects
  • The README mentions v8 is intentionally left blank, so it is not available
  • The README is truncated, so some details of v6 and v7 options are not covered here

How it compares

ProjectStarsTypeLevelUpdatedBest for
uuid (this)15.3kLibrarybeginner5 days agoJavaScript or TypeScript developers who need standard-format IDs
nanoid27.1kLibrarybeginner21 days agoJavaScript or TypeScript developers who need unique IDs for new records or objects

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.