NanoID Generator
Generate secure, URL-friendly NanoIDs in bulk with a configurable length, alphabet options, and copy or download output. Runs entirely in your browser.
What Is a NanoID
A NanoID is a short, URL-friendly unique identifier. The default form is 21 characters drawn from a 64-symbol alphabet of uppercase letters, lowercase letters, digits, hyphen, and underscore, which gives each ID about 126 bits of randomness. That is more than enough to make accidental collisions practically impossible, while keeping IDs short enough to use in URLs, file names, and API responses without escaping anything.
This generator creates NanoIDs with the official nanoid library, running entirely in your browser. The random characters come from the Web Crypto API, which is a cryptographically secure random number generator, not the predictable Math.random() that many quick scripts use.
How to Use It
- Set the quantity, up to 100 IDs per batch.
- Choose a length. The default 21 characters is the NanoID standard, and shorter IDs are fine for lower-stakes use.
- Pick the character sets for the alphabet: uppercase, lowercase, digits, and the URL-safe symbols
-and_. - Select an output format: one per line, comma separated, or a JSON array.
- Copy the output or download it as a text file. Generate New produces a fresh batch whenever you need one.
NanoID vs UUID
A UUIDv4 is 36 characters including hyphens and carries 122 random bits. A NanoID with the default settings carries 126 bits in 21 characters. In other words, NanoID packs slightly more randomness into roughly 40 percent less space, and because its alphabet is URL-safe, the ID survives being pasted into a query string, a path segment, or a file name without encoding. UUIDs win on ecosystem support: databases, libraries, and protocols recognize the UUID format natively, and it carries version and variant information. Choose UUIDs when an external system expects the standard format, and NanoIDs when compactness matters.
How Much Entropy Do You Need
Entropy is how many possible IDs the settings allow, expressed in bits: $H = L \times \log_2 A$, where $L$ is the length and $A$ is the alphabet size. The default 21-character ID over a 64-symbol alphabet gives 126 bits. Halving the alphabet costs one bit per character, so a 21-character lowercase-only ID (26 symbols) gives about 99 bits, still far beyond guessing. As a rule of thumb, IDs that are purely internal keys are safe at 64 bits or more, public-facing record identifiers should have at least 96 bits, and anything that behaves like a bearer token should have 128 bits or more. The entropy value under the result card updates with every change so you can see the trade-off directly.
Choosing a Custom Alphabet
Custom alphabets solve real problems. Dropping _ and - helps when IDs appear in systems that mangle punctuation. An uppercase-only alphabet works for codes read aloud or printed on cards, at the cost of bits per character. Removing visually ambiguous characters such as 0, O, 1, and l reduces transcription errors. Keep at least one set enabled, and remember that a shorter alphabet means you should increase the length to hold the same entropy.
Are NanoIDs Safe for Secrets
NanoID uses the same cryptographically secure randomness that token generators rely on, and 126 bits is beyond brute force. The practical risks are elsewhere: predictable IDs are never the problem, but leaking them through logs, referrer headers, or URLs is. For session tokens and password reset links, treat the ID as a secret, store only a hash of it server-side, and set an expiry. For database keys and public identifiers, a plain NanoID is ideal.
Where NanoIDs Fit Well
Use them for primary keys in distributed systems where coordination is undesirable, for invite codes and share links, for object storage file names, and for cache keys. Pair a NanoID with a prefix such as ord_ or usr_ to make logs and support tickets readable at a glance. Generate related tools include the ULID Generator when you need sortable IDs, the UUID Generator Tool for the standard 36-character format, and the Strong Password Generator when the value must be secret and memorable-worthy.
Frequently Asked Questions
Are the generated IDs truly random?
Yes. The nanoid library reads from the Web Crypto API, a cryptographically secure random source provided by your browser. It is not Math.random(), which is predictable and unsuitable for identifiers or tokens.
Can two generated IDs ever be the same?
In theory yes, in practice no. With the default 126 bits of entropy you would need to generate billions of IDs per second for many years before a collision becomes likely. Shorter IDs and smaller alphabets trade some of that safety for brevity, which the entropy readout shows.
Why does the default length stop at 64 characters?
NanoID IDs are meant to be short. Longer values stop being human-readable and are better served by other formats. If you need more entropy, a longer ID or a wider alphabet is always available within the limit.
Is the standard alphabet URL-safe?
Yes. Uppercase letters, lowercase letters, digits, hyphen, and underscore all pass through URLs, query strings, and file paths without percent-encoding. That is why the library chose them.
Is anything sent to a server when I generate IDs?
No. Generation happens in your browser with no network calls. The settings are stored in the page URL so you can bookmark or share a configuration, but no IDs or settings are transmitted anywhere.
Can I use these IDs in production?
Yes. The nanoid library is widely used in production systems, and this tool calls the same functions. For secrets such as session tokens, follow standard practice: treat the ID as confidential, hash it before storing, and give it an expiry.
What is the difference between a NanoID and a ULID?
A ULID is 26 characters in Crockford base32 and sorts lexicographically by creation time, which is useful for database keys. A NanoID is shorter, has no built-in timestamp, and hides creation time, which is preferable when IDs are public.