CruxDevCruxDev Tools Prompts
dev Utility • Zero-Server Privacy • 100% Client-Side

NanoID Generator

Generate compact, URL-safe, cryptographically strong unique IDs with configurable alphabet and length (default 21 chars).

Overview

Generate one or more NanoID identifiers with a configurable length, count, and alphabet. The default settings reproduce the standard NanoID: 21 characters from the 64-symbol URL-safe alphabet, drawn with the browser's cryptographic random number generator, entirely offline.

How It Works

Set the length (1 to 256 characters, 21 by default), the count (1 to 1000, 10 by default), and optionally replace the alphabet, which defaults to the 64-character URL-safe set of letters, digits, underscore, and dash. Press the generate button and the identifiers fill the output area, one per line. Click the output to copy the whole batch. The first batch is generated automatically when the page opens.

Step-by-Step Usage Guide

  1. Choose an ID length; keep 21 for UUID-v4-comparable uniqueness.
  2. Set how many identifiers you need, up to 1000 per batch.
  3. Optionally restrict the alphabet, for example to digits only.
  4. Generate, then click the output area to copy the list.

Technical Specifications & Standards

Each identifier is built by drawing one random byte per character with crypto.getRandomValues and mapping it through the alphabet with a modulo. With the default 64-symbol alphabet the mapping is uniform, because 64 divides 256 evenly, so a 21-character ID carries the documented 126 bits of entropy, the reason standard NanoID matches UUID v4 collision behavior in a fifth of the space. If you supply a custom alphabet whose length does not divide 256, the modulo mapping is very slightly biased toward the earlier symbols; for identifiers of typical length this is negligible, but it is not the rejection-sampling approach the reference library uses. An empty alphabet is a degenerate case that produces no usable output. Because randomness comes from the browser's CSPRNG, the identifiers are suitable for unguessable URLs and tokens; they are not, however, licensed keys or secrets with checksums. Generation is instantaneous and completely offline, so batches of 1000 are practical for seeding test data.

Targeted Use Cases

  • Creating unguessable URL slugs for shared resources or invitations.
  • Seeding test databases with realistic unique identifiers in bulk.
  • Producing short opaque tokens for client-side correlation ids.
  • Generating identifiers from a restricted alphabet, such as digits only, for manual entry.

Notes & Gotchas

  • Keep at least 21 characters with the default alphabet when unpredictability matters.
  • Prefer the default URL-safe alphabet unless you have a constraint; custom lengths can introduce slight bias.
  • Treat the IDs as random strings, not as secrets with integrity checks; there is no checksum.
  • Regenerate rather than editing an ID by hand, so entropy is not reduced.

Frequently Asked Questions

How unique is a 21-character NanoID?

With the 64-symbol default alphabet it carries about 126 bits of entropy, giving collision odds comparable to a random UUID v4 while being shorter. Collisions are not a practical concern at that size.

Are the IDs cryptographically secure?

Yes in the sense that randomness comes from crypto.getRandomValues, the browser's CSPRNG. They are unpredictable and suitable for tokens, but they are not secrets with any built-in verification.

Why is a custom alphabet slightly biased?

Each character draws one byte and takes it modulo the alphabet length. When the length does not divide 256, some symbols get one extra possible byte value. The effect is tiny for long IDs but real.

Can I generate 5000 identifiers at once?

The tool caps a batch at 1000. Generate several batches and concatenate them if you need more; each batch is independent.