JavaScript UUID and ID generation libraries

Updated Nov 2026

JavaScript UUID libraries generate unique identifiers for records, requests, and files without a central counter. A generator builds each ID from random bytes, a timestamp, or both, in a fixed format such as a standard UUID or a shorter URL-safe string. These libraries let apps and distributed services create IDs that stay unique across machines.

Popularity

uuid has the most monthly downloads in this comparison, at 1.5B.

LibraryMonthly downloadsStarsLast releaseLicense
uuid
1.5B
15.3KOct 2026MIT
nanoid
1.5B
27.1KOct 2026MIT
crypto-random-string
153.7M
594Jul 2026MIT
@paralleldrive/cuid2
115.6M
3.4KJan 2026MIT
uid
86.9M
665Mar 2023MIT
ulid
66.6M
3.4KNov 2025MIT
@lukeed/uuid
33.2M
410Mar 2023MIT
guid-typescript
28.6M
54Oct 2018ISC
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Features compared

LibraryRFC UUID generationTime sortable modeCustom alphabet
uuidBuilt-inBuilt-inUnsupported
nanoidUnsupportedUnsupportedBuilt-in
crypto-random-stringUnsupportedUnsupportedBuilt-in
@paralleldrive/cuid2UnsupportedUnsupportedUnsupported
uidUnsupportedUnsupportedUnsupported
ulidUnsupportedBuilt-inUnsupported
@lukeed/uuidBuilt-inUnsupportedUnsupported
guid-typescriptUnsupportedUnsupportedUnsupported
Built-inNot supported

Libraries and code examples

Generates standard UUID variants and provides parsing, validation and version checks.

Downloads / mo
1.5B
Stars
15.3K
Last release
14.0.3
License
MIT

Strengths

  • Generates reordered timestamp UUIDs. Choose a reordered timestamp variant when ID ordering matters.
  • Checks UUID version constraints. Combine validate and version when a field requires a specific UUID version.

Limitations

  • Current releases require ES modules. CommonJS imports are unsupported in current uuid releases.
  • Options bypass timestamp generator state. Passing options disables the internal timestamp-UUID state.

Quickstart

From README.md
$ npm install uuid
import { v4 as uuidv4 } from 'uuid';

console.log(uuidv4());

uuid examples

From open-source projects on GitHub
export function generateId(prefix?: string) {
  const id = uuidv4().replace(/-/g, '');

  if (prefix) {
    return `${prefix}_${id}`;
  }
  return id;
}

Generates random string identifiers with configurable lengths and alphabets.

Downloads / mo
1.5B
Stars
27.1K
Last release
6.0.2
License
MIT

Strengths

  • Customizes alphabet and length. Use customAlphabet to define the characters and size of generated IDs.
  • Accepts a custom random source. Use customRandom to replace the default random-byte generator.

Limitations

  • Seeded results vary across versions. Do not expect seeded output to stay identical after library upgrades.
  • Generated React keys are unstable. Use stored item IDs for React keys across renders.

Quickstart

From README.md
$ npm install nanoid
import { nanoid } from 'nanoid';

console.log(nanoid());

crypto-random-string

Generates a cryptographically strong random string.

Downloads / mo
153.7M
Stars
594
Last release
6.0.0
License
MIT

Quickstart

From readme.md
$ npm install crypto-random-string
import cryptoRandomString from 'crypto-random-string';

console.log(cryptoRandomString({ length: 16, type: 'url-safe' }));

crypto-random-string examples

From open-source projects on GitHub

@paralleldrive/cuid2

Generates identifiers and validates their format.

Downloads / mo
115.6M
Stars
3.4K
Last release
3.3.0
License
MIT

Strengths

  • Configures generated ID length. Pass length to init when the default size does not fit.
  • Includes an ID validator. Use isCuid to check a generated or supplied ID.

Limitations

  • Creation order needs another field. Store createdAt separately when records need chronological ordering.

Quickstart

From README.md
$ npm install @paralleldrive/cuid2
import { createId } from '@paralleldrive/cuid2';

console.log(createId());

Generates random unique IDs of a fixed length.

Downloads / mo
86.9M
Stars
665
Last release
2.0.2
License
MIT

Quickstart

From readme.md
$ npm install uid
import { uid } from 'uid';

console.log(uid());

uid examples

From open-source projects on GitHub

Generates lexicographically sortable identifiers containing a time component.

Downloads / mo
66.6M
Stars
3.4K
Last release
3.0.2
License
MIT

Strengths

  • Maintains same-timestamp order. Use monotonicFactory when IDs generated together must remain ordered.
  • Recovers the encoded timestamp. Use decodeTime to read the timestamp stored in a ULID.

Limitations

  • Canonical IDs have fixed length. Use Nano ID when the ID length must be configurable.
  • IDs expose creation time. The timestamp can be recovered with decodeTime.

Quickstart

From README.md
$ npm install ulid
import { ulid } from 'ulid';

console.log(ulid());

@lukeed/uuid

Generates random UUIDs for Node.js and the browser.

Downloads / mo
33.2M
Stars
410
Last release
2.0.1
License
MIT

Quickstart

From readme.md
$ npm install @lukeed/uuid
import { v4 } from '@lukeed/uuid';

console.log(v4());

guid-typescript

Generates GUIDs in TypeScript.

Downloads / mo
28.6M
Stars
54
Last release
1.0.9
License
ISC

Quickstart

From README.md
$ npm install guid-typescript
import { Guid } from 'guid-typescript';

console.log(Guid.create().toString());

guid-typescript examples

From open-source projects on GitHub
public static getDefaultPath() {
    return path.join(
      tl.getVariable("Agent.TempDirectory") as string,
      TaskReport.getDefaultPathTemplate().replace("<GUID>", Guid.create().toString()),
    );
  }

FAQ

uuid suits code that needs standard UUIDs with parsing and validation. nanoid suits short, URL-safe IDs with a custom alphabet. ulid suits IDs that sort by creation time.

nanoid generates short random string IDs from a URL-safe alphabet. Both the length and the alphabet are configurable.

A UUID is a standard identifier written as hexadecimal digits in five groups separated by hyphens. Random UUIDs make collisions unlikely enough that systems generate them without coordination.

A ULID starts with a timestamp followed by random characters. That prefix sorts ULIDs in creation order, unlike random UUIDs.

@paralleldrive/cuid2 generates collision-resistant IDs that start with a letter and do not reveal their creation time. A UUID follows a standard format that databases and APIs recognize.

For coding agents

Found your UUID and ID generation library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official