Generate short, URL-friendly NanoIDs online with a secure random source. Set the size, count, and alphabet, then copy compact unique IDs, all in-browser.
Runs entirely in your browser — your data never leaves your device.
How to use NanoID Generator
What it does & when you need it
You need a compact, random identifier — a short link code, a public-facing record
key, an invite token — and a 36-character UUID feels bulky in the URL. A NanoID
packs the same collision resistance into far fewer characters using a 64-symbol
URL-safe alphabet (A–Z, a–z, 0–9, plus _ and -). This tool generates
them in batches with a cryptographically secure random source, so you can copy a
list of ready-to-use IDs in one click.
Everything happens in your browser. IDs are drawn from your device's
crypto.getRandomValues and are never sent anywhere, so the tool works offline
and keeps unreleased keys private.
How to use
Set Size — the number of characters per ID. The default of 21 matches
UUID v4 for collision safety; shorten it when space is tight.
Set Count for how many IDs you want in one batch.
Optionally edit the Alphabet. Restrict it to digits for a numeric code, or
to lowercase hex for a compact token. Leaving it empty falls back to the
standard 64-character set.
Press Generate (or Ctrl/Cmd + Enter) to roll a fresh batch, then
Copy the whole list.
Things worth knowing
Size is a collision-risk decision, not just aesthetics. A 21-character NanoID
carries about 121 bits of entropy — enough to mint billions of IDs before a
collision becomes plausible. Drop to 12 characters and you still have roughly 71
bits, comfortable for most application records, but the shorter you go the sooner
duplicates become a real risk. Match the length to how many IDs you expect to
create.
A smaller alphabet needs a longer ID. Entropy per character is the base-2 log
of the alphabet size, so switching from 64 symbols to 10 digits cuts each
character from 6 bits to about 3.3. If you shrink the alphabet, lengthen the ID
to hold the same collision resistance.
The randomness is uniform and secure. Every character comes from a CSPRNG,
not Math.random, and the tool uses rejection sampling when mapping random bytes
onto your alphabet, so no character is subtly more likely than another. When you
need a time-sortable database key instead, reach for the
UUID Generator; for high-entropy secrets rather than
identifiers, use the Password Generator.
Examples
Default 21-character IDs
size 21, 5 ids
Five standard NanoIDs — the drop-in replacement for a UUID primary key, only shorter.
Short 10-character codes
size 10, 10 ids
Compact IDs for short links or coupon codes where every character in the URL counts.
Numeric-only alphabet
size 8, 3 ids, alphabet 0123456789
Restrict the alphabet to digits for an 8-digit numeric reference code.
Frequently asked questions
What is a NanoID and how is it different from a UUID?+
A NanoID is a short, random string ID from a 64-character URL-safe alphabet (A–Z, a–z, 0–9, plus _ and -). A 21-character NanoID carries about the same collision resistance as a UUID v4 but in 21 characters instead of 36, with no hyphens to escape. It is ideal for URLs, short links, and public-facing keys where compactness matters.
How long should my NanoID be?+
The default of 21 characters gives roughly 121 bits of entropy — collision-safe for billions of IDs, matching UUID v4. You can shorten it to save space: a 12-character ID still has about 71 bits, fine for most application records. Use the collision math for your expected volume; more IDs or higher stakes mean more characters.
Is the randomness cryptographically secure?+
Yes. Every character is drawn from crypto.getRandomValues, the browser's cryptographically secure generator, not Math.random. The tool also uses rejection sampling when mapping random bytes onto your alphabet, so no character is more likely than another due to modulo bias — the distribution stays perfectly uniform.
Can I use my own alphabet?+
Yes. Provide any set of characters — for example digits only for a numeric code, or lowercase hex for a compact token. A smaller alphabet lowers entropy per character, so you may need a longer ID to keep the same collision resistance. An empty alphabet safely falls back to the standard 64-character set.
Are these IDs generated privately?+
Completely. IDs are created locally in your browser and never sent anywhere, and the tool keeps working offline once loaded. You can generate keys for an unreleased feature or an internal system without any value leaving your machine.