Nano ID is a small, fast, and secure URL-friendly unique string ID generator for JavaScript. It is just 127 bytes (minified and brotlied), has no dependencies, and uses a larger alphabet than UUID (A-Za-z0-9_-) to reduce ID size from 36 to 21 symbols. It is 50% faster than native crypto.randomUUID() and has been ported to over 20 programming languages.
- Includes a CLI for generating IDs from the terminal via `npx nanoid` with options for custom size and alphabet
- Provides a TypeScript API for casting generated strings into opaque string types
- Has a `non-secure` variant for environments without hardware random generators, though it is slower than the secure version
- Built by Evil Martians, a design and engineering consultancy for developer tools, AI, and cybersecurity startups
This article explores 7 popular approaches to generating unique IDs in distributed systems, including UUIDs, database auto-increment, Snowflake IDs, Redis-based generation, NanoID, hash-based IDs, and ULIDs.
Collision-resistant ids optimized for horizontal scaling and sequential lookup performance.