NanoID Generator
Generate compact, URL-safe NanoIDs with a custom length, count, and alphabet - shorter than a UUID and safe to drop straight into links.
- Free, no account
- No watermark
- No usage limit
About the NanoID Generator
A NanoID is a short, random, URL-safe ID, the kind you paste into a URL or a database row and then forget about. This generator mints a batch of them right in your browser, and it does one thing almost every other NanoID generator skips: it tells you, live, how many IDs you can safely make at the length you picked before two of them have even a 1% chance of matching.
That number is the thing that actually matters with NanoID, and most tools leave you to guess it. Here you slide the length and the tool runs the birthday math, then prints the safe count right under the output. Leave it at 21 characters, the default the original NanoID library ships with, and you could mint IDs for centuries before a clash gets likely. Cut it to 8 and that safety drops through the floor, and most people don't find that out until a collision turns up in production, the worst possible place to learn it.
Everything runs on your machine. The IDs, your custom alphabet, the count, none of it is uploaded or saved. And the randomness is cryptographic, drawn from your browser's secure random generator, so an ID from here is a genuine unpredictable token an attacker has no way to guess ahead.
How to use
- Set the ID length with the slider, 1 to 64. Leave it at 21 for a standard NanoID, shorten it for a compact code, or lengthen it for extra collision headroom.
- Choose how many you need, 1 to 100. A first batch appears the moment the page loads, so you see the shape before committing.
- Pick an alphabet preset, the default 64-symbol URL-safe set, URL-friendly, Numbers only, Lowercase plus digits, or No look-alikes, depending on where the ID is headed.
- Or type your own alphabet in the custom box. The generator draws only from what you type and ignores repeats so the odds stay even.
- Click Regenerate for a fresh batch, and Copy all to grab the list, one ID per line, ready for code, a spreadsheet, or a config file.
Keep an eye on the collision hint below the output as you tune. It climbs from thousands to billions every time you add a character or widen the alphabet.
Picking the right length (the only decision that matters)
Length and alphabet size are the two knobs, and length is the one people get wrong. Shortening an ID costs you safety fast, and not in a straight line. Every character you cut divides the pool of possible IDs by the size of the alphabet, so going from 21 characters down to 10 shrinks that pool by a factor of billions. The birthday problem makes it worse than instinct expects, because two IDs start clashing near the square root of the total space, long before you've used up anywhere close to all of it.
That square-root threshold is exactly what the collision hint shows you. It reads whatever length and alphabet you've dialed in and prints how many IDs you could generate before any two have a 1% chance of matching. This is the part of the tool I'd actually reach for, it turns a question you'd normally answer with a birthday-bound formula and a calculator into a number sitting right there while you slide.
A couple of numbers it saves you from getting wrong. Numbers-only at 8 characters looks reasonable, but the collision hint warns you'll be risking a clash after only a thousand or two IDs, which is nothing for a real system. A default 21-character ID is safe for basically any app you'll ever build. When unsure, go longer, the extra characters cost a byte or two and buy orders of magnitude of headroom.
Alphabets, presets, and the look-alike problem
The default alphabet is the 64-symbol set the original NanoID uses: A to Z, a to z, 0 to 9, plus an underscore and a hyphen. Every one of those is safe in a URL with no escaping, which is the whole point of NanoID. But you can swap the set, and a couple of presets fix real headaches.
The one worth calling out is No look-alikes. If a code is ever going to be read over the phone or typed off a printed receipt, the default set becomes a real problem, because 0 and O, and 1 and lowercase l and capital I, all look too similar and people mistype them. No look-alikes strips those confusable characters out, so a voucher code or a support ticket ID survives a human keying it in by hand. So you get fewer mistyped entries, and fewer support calls from someone who keyed the code in wrong.
The rest cover the common cases. URL-friendly drops the underscore and hyphen so the ID survives a double-click select. Numbers only suits systems that take digits and nothing else. Lowercase plus digits is for case-insensitive storage, where Abc and abc must never count as two different IDs. Or type your own set into the custom box and the generator draws only from those. It dedupes as you type, so a character pasted twice still counts once, and you need at least two different characters, since a one-symbol alphabet can only ever make the same string.
When the ID has to be unguessable
Most of the time a NanoID is just a label, and any old randomness would do. But the moment an ID guards something, a password-reset link, an invite token, an unlisted share URL, predictability turns into a security hole. Plenty of quick ID snippets lean on Math.random. That function is built for speed and spreads its values fairly evenly, but it makes no promises about being unpredictable. Watch enough of its output and the next value is guessable, so an attacker can predict the next token you hand out.
This generator pulls from your browser's cryptographic random source instead, the same class of randomness used for actual crypto, and its output can't be reverse-engineered from earlier values. One smaller detail matters too: it draws every character with even odds, so no symbol shows up more often than the rest. Naive generators skew toward the front of the alphabet. It sounds like a rounding error, but that bias quietly shrinks your effective ID space below what the length promised, so the collision numbers you're counting on come out optimistic.
Frequently asked questions
Why use a NanoID instead of a UUID?
Mostly size. A default NanoID is 21 characters against a UUID's 36, roughly 40% less string for the same practical uniqueness, and its alphabet is built to sit in a URL untouched. A UUID still wins when something on the other end demands that exact format, a Postgres uuid column or a Windows GUID being the usual culprits. NanoID is the better pick once the ID has to live somewhere a person actually sees it, like a link or a coupon code. One caveat, a plain random NanoID doesn't sort by creation time, so if yours need to line up chronologically you want a sequential scheme instead.
Can I paste a NanoID straight into a link without encoding it?
With the default or URL-friendly alphabet, yes. Both use only characters that need no percent-encoding in a path or query string, so a fresh ID drops into a URL, an anchor, or a cookie value untouched. Build a custom alphabet with characters outside that safe set and you're back to encoding them yourself, so stick to the URL-safe presets when the ID is bound for a link.
Will regenerating with the same settings give me the same IDs?
No. Every batch is an independent draw, so clicking Regenerate with the same length and alphabet still hands you a completely different set. There's no seed to fix and no way to reproduce a specific batch, which is exactly what you want from a random identifier. Copy the batch you like before you leave, refreshing the page won't bring it back.
What should I do if a NanoID ever collides in my database?
Put a unique constraint on the column and let it do its job. On the astronomically rare clash the insert fails, you catch it, generate a fresh ID, and retry. At a sensible length you'll realistically never trip it, and if you do, the ID is too short for your volume, so add a few characters. IDs made here are plain strings with no hidden checksum, so they mix freely with ones the nanoid library produces at the same length.
Why does my custom alphabet count fewer characters than I typed?
Because it removes duplicates before using your set. Paste aaab and it draws from ab, since a repeated character would quietly weight the odds toward it. Tabs and line breaks get stripped as well, though a plain space counts as a real character if you put one in. The note under the box shows the real count of unique characters, so check that if the number looks off.
Can I use a NanoID as a password or secret key?
The randomness is cryptographic and unguessable, so it's built the right way to be one. But a NanoID is really meant to be a label something looks up, and asking a person to memorize one is a different job. For a token a machine stores and checks, like an API key or a reset link, a long NanoID is a solid choice. For something a person has to remember and type, use a passphrase generator instead, random characters are miserable to key in by hand.
Can I generate more than 100 at a time?
Not in one batch, 100 is the cap. Set the count, click Regenerate, Copy all. Need thousands? Regenerate a few times, each batch is independent and won't overlap in practice, or wire the nanoid library into your code for bulk generation. This tool is tuned for quick handfuls and trying out settings, not million-row exports.