Embed this tool on your site
About this tool
The Nano ID Generator creates compact, secure, URL-friendly unique identifiers in the style of the Nano ID library — a modern alternative to UUID designed for use in URLs, tokens, and short unique codes. IDs default to 21 characters using the URL-safe alphabet (A-Za-z0-9_-), providing ~126 bits of entropy. A Length slider sets 8 to 64 characters, a Count slider produces 1 to 50 IDs per click, and the Alphabet menu offers Default (URL-safe, 64 chars), Alphanumeric (62 chars), Numeric only (10 chars) or a Custom alphabet of at least two characters, for example lowercase letters for readable slugs. The generator uses a cryptographically secure random source (Web Crypto API) with the same mask-and-reject approach as the nanoid npm package, so every character of the alphabet is equally likely.
Why use it
Cryptographically secure random source (Web Crypto API).
Configurable length (8-64) and alphabet for many ID formats.
Shorter than UUID (21 chars vs 36) for the same entropy level.
Preset alphabets for URL-safe, alphanumeric and numeric IDs, plus a custom option.
Smaller code footprint than UUID libraries — the algorithm is roughly 130 lines, ideal for tight bundle budgets.
Implementations exist in over 20 languages, so client and server can produce IDs in the same format.
How to use
- Set the ID length with the Length slider (8-64, default 21 characters).
- Choose an alphabet: Default (URL-safe), Alphanumeric, Numeric only, or Custom… to type your own character set.
- Set the Count slider (1-50) and click Generate.
- Click Copy next to an ID, or Copy All to copy the whole batch one per line.
- Use Copy All to paste a batch into a database fixture or a test of your unique-index constraints.
When it helps
- 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
01Default URL-safe ID (21 chars)
InputLength: 21, Alphabet: Default (URL-safe, 64 chars)
Expected resultV1StGXR8_Z5jdHi6B-myT
02Numeric code (8 digits)
InputLength: 8, Alphabet: Numeric only (10 chars)
03Lowercase short slug (8 chars)
InputLength: 8, Alphabet: Custom… abcdefghijklmnopqrstuvwxyz
04Custom no-vowel alphabet
InputLength: 10, Alphabet: Custom… bcdfghjklmnpqrstvwxyz0123456789
Expected resultk7z3p9n2qm
Tips
- For numeric codes choose Numeric only and the minimum length of 8 — and expect collisions sooner than with letters, 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.
- Keep custom alphabets to plain ASCII letters, digits, - and _; characters such as < or " are inserted into the result list as HTML and can display or copy incorrectly.
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, down to the slider minimum of 8, but work out the entropy first (length × log2 of the alphabet size); the tool does not display it. 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 ports in Python, Go and Rust offer the same option. Pick Custom… in the Alphabet menu and type at least two characters.
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.
A LITTLE HELP. A LOT DONE.
Good tools.
Great flow.
Your shortcut to the everyday. Create, convert, calculate,
and get back to what you love.
✳
✳
✓ Free to use✓ No sign-up✓ 500+ possibilities