About the Nano ID Generator
Nano ID is a popular way to make short, URL-safe unique identifiers. It uses a 64-character alphabet (letters, digits, hyphen and underscore) and the browser's secure random source, so a 21-character Nano ID has a collision probability comparable to a UUID while being much shorter and safe to drop straight into a URL or filename. This tool generates them at any length you choose.
The arithmetic is worth knowing before you pick a length. Sixty-four possible characters means six bits each, so the default 21 characters carry 126 bits of randomness, slightly more than the 122 bits in a UUID v4. Cut it to 10 characters and you have 60 bits, which is comfortable for a few thousand rows and starts producing collisions at millions, so choose the length from your expected volume rather than by eye. The two punctuation characters are the thing to watch: an ID can begin with a hyphen, which some command-line parsers read as the start of a flag, so quote it when passing IDs to a script.
It is a good fit for short links, public-facing record IDs and anywhere a UUID would be unnecessarily long or contain awkward characters. Because it needs no coordination, a Nano ID can be minted on the client before the record is saved, which is what makes optimistic UI updates and offline queues straightforward. For time-sortable IDs use a ULID or UUID v7; for a readable identifier built from a title rather than random bytes, the Slug Generator.
How to use
- Set the length and how many to generate.
- Copy or download the IDs.
- They are safe to use directly in URLs.
Common questions
- How long should a Nano ID be?
- The default 21 characters gives collision safety similar to a UUID. Shorter IDs are fine at lower volumes.
- Is it URL-safe?
- Yes. The alphabet is A-Z, a-z, 0-9, hyphen and underscore, all safe in URLs.
- Is the randomness secure?
- Every character is drawn with crypto.getRandomValues, so the IDs are unpredictable rather than pseudo-random.