NanoID Generator
Generate short, URL-safe random IDs in the NanoID style — choose the length and alphabet and see how many bits of randomness each ID carries.
How to use this tool
Steps for using the UUID Generator.
- NanoID is selected with the URL-safe alphabet and 21 characters — the usual NanoID default.
- Change the Length (4–64) and the Alphabet: URL-safe, letters and digits, lowercase and digits, hexadecimal or digits only.
- Check the entropy shown for your settings — more bits means a lower chance of duplicates.
- Set How many, then Copy all or Download in the format you need.
Example
Default: 21 URL-safe characters
Generatelu_UW1VoJEqwSr4jWrQThCommon use cases
- Short public IDs in URLs, such as share links and invite codes.
- Client-side IDs for UI elements, drafts and offline records.
- Readable reference codes using digits only or letters and digits.
- Random tokens in hex for test data and fixtures.
Length, alphabet and entropy
A NanoID is a random string drawn from an alphabet. The default here matches the popular NanoID library: 21 characters from a 64-character URL-safe alphabet (A–Z, a–z, 0–9, _ and -), which gives 126 bits of randomness — slightly more than a UUID v4 in 15 fewer characters.
Each character carries log₂(alphabet size) bits: 6 for URL-safe, about 5.95 for letters and digits, about 5.17 for lowercase and digits, 4 for hex and about 3.32 for digits only. Multiply by the length to get the entropy this page shows. Fewer bits mean a higher chance that two IDs collide, so shorten IDs only as far as your volume allows.
Every character is chosen with rejection sampling from the browser's cryptographic random generator: random bytes that would favour some characters over others are discarded, so each character in the alphabet is equally likely.
This is a NanoID-style generator built into the page, not the nanoid npm package itself, but the format is the same: a plain random string with no timestamp or structure. Need IDs that sort by time? Use a ULID or UUID v7.
Limitations
- Length from 4 to 64 characters, up to 1000 IDs per batch.
- Short lengths and small alphabets carry few bits — check the entropy before relying on uniqueness at scale.
- No timestamp or ordering: NanoIDs sort randomly.
Frequently asked questions
How long should a NanoID be?
21 URL-safe characters (126 bits) is the common default and is safe for practically any volume. Shorter IDs are fine for small datasets, but every character you remove makes collisions more likely.
Is NanoID better than UUID?
It is shorter and URL-friendly for the same randomness, but it isn't a standard format. Use a UUID when a database, API or library expects one; use NanoID when you control both ends and want compact IDs.
Can I use NanoID for secret tokens?
Its randomness comes from a cryptographic generator, so a long ID (for example 32 URL-safe characters) is hard to guess. Treat it like any secret: send it only over HTTPS and store it carefully.
Which alphabet should I pick?
URL-safe gives the most bits per character. Letters and digits avoid _ and -; lowercase and digits suits case-insensitive systems; digits only is for numeric codes.