UtilityKit

500+ fast, free tools. Most run in your browser only; Image & PDF tools upload files to the backend when you run them.

Nano ID Generator

Generate secure, URL-friendly unique string IDs with customizable alphabet and length using the Nano ID standard.

About Nano ID Generator

The Nano ID Generator creates compact, secure, URL-friendly unique identifiers following the Nano ID specification — a modern alternative to UUID designed for use in URLs, tokens, and short unique codes. Nano IDs default to 21 characters using a URL-safe alphabet (A-Za-z0-9_-), providing ~126 bits of entropy, but both the alphabet and length are fully configurable. You can use numeric-only alphabets for PIN codes, lowercase-only for readable slugs, or custom character sets for domain-specific needs. The generator uses a cryptographically secure random source (Web Crypto API) just like the popular nanoid npm package.

Why use Nano ID Generator

  • Cryptographically secure random source (Web Crypto API).
  • Fully configurable length and alphabet for any ID format.
  • Shorter than UUID (21 chars vs 36) for the same entropy level.
  • Preset alphabets for URL-safe, numeric, and custom use cases.
  • Smaller code footprint than UUID libraries — the algorithm is roughly 130 lines, ideal for tight bundle budgets.
  • Available in over 20 languages with bit-identical output, so client and server can produce interchangeable IDs.

How to use Nano ID Generator

  1. Set the ID length (default 21 characters).
  2. Optionally customize the alphabet or choose a preset (URL-safe, numeric, alphanumeric).
  3. Click Generate or enter a count for bulk generation.
  4. Click Copy to copy generated IDs to your clipboard.
  5. Watch the live entropy meter as you adjust settings — aim for at least 90 bits for opaque tokens and 60+ bits for typical app slugs.
  6. Use Bulk generation with Copy All to seed a database fixture or stress-test your unique-index constraints in one paste.

When to use Nano ID Generator

  • Generating short unique tokens for URLs, session IDs, or API keys.
  • Creating compact IDs for database records where UUID's length is wasteful.
  • Producing numeric-only codes (PIN codes, order numbers).
  • Generating readable short slugs for shareable links.
  • Generating short, opaque sharing tokens (e.g. file links) where 21-character IDs are too long for human-friendly URLs.
  • Producing per-message IDs in chat or notification systems that need cryptographic uniqueness without a central counter.

Examples

Default URL-safe ID (21 chars)

Input: Length: 21, Alphabet: A-Za-z0-9_-

Output: V1StGXR8_Z5jdHi6B-myT

Numeric PIN code (6 digits)

Input: Length: 6, Alphabet: 0123456789

Output: 738241

Lowercase short slug (8 chars)

Input: Length: 8, Alphabet: abcdefghijklmnopqrstuvwxyz

Output: kqpzwxnv

Custom no-vowel alphabet

Input: Length: 10, Alphabet: bcdfghjklmnpqrstvwxyz0123456789

Output: k7z3p9n2qm

Tips

  • For PIN codes set the alphabet to numeric only (0123456789) and the length to 6 — but expect collisions long before a million IDs because numeric-only entropy is only ~3.32 bits per character.
  • Avoid lowercase-only alphabets in case-insensitive contexts like email addresses or DNS — collisions get worse if downstream tooling normalizes case.
  • When picking length, target at least 21 characters with the default alphabet for UUID-equivalent uniqueness; shorten only when you have a small known ID space.
  • Do not mix Nano IDs and UUIDs in the same primary-key column — sort orders are different and any UNIQUE index will balloon if it has to compare across formats.
  • If you expose Nano IDs in URLs, prefer the default URL-safe alphabet over alphanumeric so dashes and underscores stay intact through encoding layers.
  • Generate IDs on the client to avoid server round-trips, but always validate the format and length on the server before persisting — never trust user-supplied IDs blindly.
  • The Web Crypto API is required; Nano ID falls back to non-secure Math.random in environments without crypto.getRandomValues, which is unsafe for tokens or session IDs.

Frequently Asked Questions

How does Nano ID compare to UUID?
Nano ID is shorter (21 chars vs 36) for equivalent entropy, uses a URL-safe alphabet by default, and uses a cryptographically secure RNG. UUID has broader ecosystem tool support.
Is the generated ID truly random?
Yes. The tool uses the Web Crypto API (crypto.getRandomValues) which is cryptographically secure.
What is the default entropy?
21 characters from a 64-symbol alphabet provides approximately 126 bits of entropy — comparable to UUID v4.
Can I use it for database primary keys?
Yes. Nano IDs are commonly used as primary keys in web applications. For insertion-order sorting, use ULID instead.
Is the nanoid library used?
This tool implements the Nano ID algorithm directly in the browser using the Web Crypto API — no npm package is loaded.
Are Nano IDs sortable like ULIDs?
No. Nano IDs are pure random with no time component, so they sort lexicographically but not chronologically. Use ULID or UUID v7 if insertion-order sorting matters.
Can I shorten the ID below 21 characters safely?
Yes, but watch the entropy meter — at 10 characters with the default alphabet you have only 60 bits, where the birthday paradox predicts a 1% collision chance after about 35 million IDs.
Is the alphabet customization standard?
Yes. The reference Nano ID library exposes a customAlphabet helper, and other languages (Python, Go, Rust) implement the same option with identical output.

Explore the category

Glossary

Nano ID
A small JavaScript library and ID format that produces compact, URL-safe, cryptographically random unique identifiers, typically 21 characters long.
URL-safe alphabet
The 64-symbol set A-Z, a-z, 0-9, plus underscore (_) and dash (-) — every character can appear in a URL without percent-encoding.
Entropy
The information-theoretic randomness of an ID, computed as length × log2(alphabet size); a 21-character URL-safe Nano ID has about 126 bits.
Collision probability
Likelihood that two independently generated IDs are identical; depends only on entropy. 126 bits matches UUID v4 collision profile.
Web Crypto API
Browser-native interface (crypto.getRandomValues, crypto.subtle) that provides cryptographically secure randomness without external dependencies.
Custom alphabet
A user-supplied string of characters used in place of the default. Smaller alphabets produce shorter, lower-entropy IDs; larger alphabets produce more compact IDs.
Bias-free distribution
A property of correct Nano ID implementations where every character of the alphabet has equal probability, achieved by rejection sampling on raw random bytes.