NanoID Generator
Generate NanoIDs locally in batches: 21 chars by default, URL-safe alphabet (A-Za-z0-9_-) by default — shorter than UUID, ideal as IDs.
>_ USAGE GUIDE
Generate NanoIDs locally in batches: 21 characters by default from the URL-safe alphabet A-Za-z0-9_-, with adjustable length and character set. Click and a batch is produced — copy one or several straight into your code or data.
NanoID is a popular compact unique ID: compared with UUID it is much shorter (21 chars by default vs UUID's 36), uses a naturally URL-safe alphabet, and is backed by cryptographically secure randomness. It suits database primary keys, short-link identifiers, filenames, and IDs embedded in shareable URLs — short, collision-resistant, and URL-ready all at once.
- Generate a batch: get as many IDs as you need and copy them into code or data
- Adjust the length: shorten to 10–12 for terser IDs or lengthen for extra headroom
- Customize the alphabet: the default is already URL-safe; change it only for special cases
- Preview with the sample: load a sample to gauge how different lengths look and how dense the output is
Generation runs entirely in your browser, drawing on cryptographically secure randomness (WebCrypto) — nothing is uploaded.
>_ FAQ
Q1 · How do NanoID and UUID differ? When do I use which?
UUID v4 is 36 characters (with hyphens) and 122 random bits — collision-safe but long. NanoID is 21 characters by default and fits more randomness into a shorter string by using a larger 64-character URL-safe alphabet. Choose NanoID when you want something short, URL-ready, and random enough; choose UUID when you must interoperate with existing UUID fields or standards. Both are sound unique-ID choices.
Q2 · Why is the default length 21?
21 is the recommended default: across a 64-character alphabet, 21 characters provide collision protection on the same order as UUID while staying visually short. For terser output, drop to 10–12 (collision odds rise but remain fine for most business use); for extra safety, lengthen beyond 25. It is a tunable trade-off.
Q3 · Can NanoIDs collide?
In theory yes, but with negligible probability. Every random ID can collide; NanoID compresses that probability to a negligible level through sufficient length and full randomness. If you need a strict guarantee of uniqueness, use auto-increment/ordered IDs or let the database enforce the primary key — random IDs are best for offline generation and unpredictability.
Q4 · Is NanoID's alphabet safe in URLs and filenames?
The default A-Za-z0-9_- includes only characters safe in URLs and common filenames — - and _ need no escaping and there is no +, /, or = that would require percent-encoding. A NanoID can be placed directly into URL paths, query strings, and filenames without transformation, unlike many base64 strings.
Q5 · Is NanoID truly unpredictable/secure?
Default generation uses cryptographically secure random numbers (the same source as UUID v4), so the output cannot be predicted or enumerated — suitable for temporary tokens, share keys, and other identifiers that must resist guessing. If you do not need anti-guessing, shorter IDs are acceptable. Never build the source from a predictable seed or timestamp.