Generate Compact, URL-Safe Random IDs
This nanoid generator creates NanoIDs, a compact unique id generator format built for exactly one job: a short, URL-safe, hard-to-guess random string, nothing more. The default 21-character ID drawn from a 64-character alphabet has roughly the same collision resistance as a UUID v4 while being noticeably shorter, useful anywhere a full 36-character UUID feels oversized, a URL slug, a session token, a client-generated database key.
How to Use This NanoID Generator
Set Count to how many IDs you need (1 to 100 per request) and Size to how many characters each one should be (1 to 128, default 21). Leave Custom alphabet blank to use the standard URL-safe alphabet (A-Z, a-z, 0-9, underscore, and hyphen), or set your own, digits-only for a numeric ID, lowercase-only for a case-insensitive one, whatever your system needs. Click Generate to generate nanoid output instantly, then copy the list or download it as a text file.
NanoID vs UUID: How They Actually Compare
The nanoid vs uuid question comes up often since both solve "give me a random unique string", here's the real comparison:
| NanoID (default) | UUID v4 | |
|---|---|---|
| Length | 21 characters | 36 characters (with hyphens) |
| Alphabet | 64 characters, customizable | Fixed hexadecimal + hyphens |
| Randomness | ~126 bits (default size/alphabet) | 122 bits |
| Format | Plain string, no fixed structure | Fixed 8-4-4-4-12 hex groups |
| Standard | No formal spec, widely adopted convention | RFC 9562 |
Custom Alphabets: What's Actually Supported
A crypto random id generator is only as safe as its randomness source, every character here comes from Node's crypto.randomBytes with rejection sampling to keep every character in the alphabet equally likely, no modulo bias toward the earlier characters the way a naive byte % alphabet.length would produce. A custom alphabet can have up to 256 unique characters (beyond that, a single random byte can't evenly cover every character, so it's rejected outright rather than silently biased or hung), and duplicate characters aren't allowed since a repeated character would just make one symbol more likely to appear than the others.