D

Nano ID Generator

Generate compact, URL-safe Nano IDs with custom alphabet and size — using the nanoid library.

Runs 100% in your browser — nothing is uploaded

About this tool

The Nano ID Generator creates small, secure, URL-friendly unique identifiers using the nanoid library. The default output is a 21-character string from a URL-safe alphabet (A-Za-z0-9_-), chosen with cryptographically secure randomness. You can customise the length (4–64 characters) and provide a custom alphabet for domain-specific ID formats.

Nano IDs are a popular alternative to UUIDs in JavaScript/TypeScript applications: they are more compact (21 vs 36 characters), URL-safe by default, and have no hyphen separators. The collision probability of a 21-character Nano ID (with the default alphabet of 64 characters) is comparable to UUID v4 for practical purposes.

Custom alphabets let you generate IDs that match specific constraints: lowercase-only for case-insensitive systems, numeric-only for numeric identifiers, or any character set your application requires. All generation uses the browser's crypto.getRandomValues — no server, no network request.

Frequently asked questions

How does Nano ID compare to UUID?
UUID v4 is 36 characters (32 hex + 4 hyphens) and encodes 122 bits of randomness. A 21-character Nano ID with the default 64-character alphabet encodes ~126 bits of randomness in a more compact format that is URL-safe by default.
When should I use a custom alphabet?
Use a custom alphabet when your system has character restrictions: lowercase-only databases, numeric-only systems, or IDs that must be typeable without special characters. Shorter alphabets require longer IDs to maintain the same collision resistance.
What length should I use?
The default 21 characters provides ~126 bits of randomness — sufficient for any practical application. If you shorten the ID or restrict the alphabet, calculate the collision probability for your expected ID count.
Is Nano ID cryptographically secure?
Yes. It uses crypto.getRandomValues (or crypto.randomFill in Node.js) — the same CSPRNG used for TLS key generation. It also avoids the modulo bias issue that affects naive random character selection.