NanoID Generator
Short random IDs from an alphabet you control. Default is 21 URL-friendly characters. This is not a UUID and not a sort-by-time ULID.
Rated 4.7 out of 5 based on 481 reviews
How to generate a NanoID
- Leave Length at 21 unless your system documents another size. Minimum is 2, maximum is 64.
- Leave the alphabet on the URL-friendly default, or edit it. It must contain at least two characters.
- Set Count if you need a list, then generate.
- Paste the ID where a public key belongs. Use a UUID when the receiver expects 8-4-4-4-12 hex.
NanoID
Compact random identifier from a custom alphabet
| Default length | 21 characters |
|---|---|
| Default alphabet | A-Z, a-z, 0-9, underscore, hyphen (URL-friendly) |
| Sampling | Unbiased Web Crypto index into the alphabet |
| Not a UUID | No version nibble, no 128-bit canonical layout |
| Collision risk | Falls as length and alphabet size grow. Short IDs collide sooner |
| Sort order | Not time-sortable. Use ULID when you need time order |
URL-friendly by default
The default alphabet is A-Z, a-z, 0-9, underscore, and hyphen. Those characters survive in paths and query strings without percent-encoding. You can shrink the alphabet, but a tiny alphabet raises collision risk at the same length. The alphabet must have at least two symbols. This page does not add a checksum.
Unbiased sampling
Each character is drawn with an unbiased integer in 0 .. alphabet.length - 1. That avoids the modulo bias you get from a naive random % n. Web Crypto supplies the bits. Math.random is not used. Changing the alphabet changes both appearance and entropy per character.
Collision risk depends on length
A 21-character ID from a 64-symbol alphabet is the usual NanoID default and is ample for many apps. A 2-character ID is a toy and will collide quickly. This generator does not talk to your database, so it cannot promise global uniqueness. Enforce a unique index where the ID is stored. For opaque tokens that are not IDs, see the random string page.
Bulk IDs stay in this tab
Count goes to 1000 lines. Nothing is uploaded. Treat IDs as public labels unless you also hide the records they point to. NanoID is not a password.