talira

Tiny, secure, URL-friendly unique string ID generator for JavaScript

open sourceMITfree

Nano ID generates short, URL-friendly unique IDs in JavaScript using a hardware random generator. Its default IDs are 21 characters from A-Za-z0-9_- with 126 random bits, so collisions are about as unlikely as with UUID v4's 122 bits in 36 characters. It's 117 bytes minified and brotlied with no dependencies, supports custom alphabets and sizes, has a non-secure variant for speed, and runs as a CLI with npx nanoid. It's built by Evil Martians and ported to over 20 other languages.

Problems it solves

  • generate short unique IDs for URLs or database rows in JavaScript
  • make random IDs shorter than a UUID that are still safe from collisions
  • get a random ID from the terminal without installing anything

Features

  • 21-character URL-safe IDs from a hardware random generator
  • 117 bytes minified and brotlied, no dependencies
  • custom alphabet and size with customAlphabet
  • non-secure variant for speed where randomness quality doesn't matter
  • CLI: npx nanoid with --size and --alphabet
  • ports in over 20 programming languages

Limitations

  • Version 6 supports Node.js 22, 24 and 26 or newer only.1

Alternatives

The same job

These do what Nano ID does.

  1. uuid Generates RFC 9562 UUIDs in JavaScript and TypeScript

Compare Nano ID with the top 3