Nano ID Generator
Your new Nano ID is ready below. Change the length or alphabet if you need to. ClickTap Copy to use it, or Generate for a fresh one.
Pick a length from 2 to 64.
Use at least 2 different characters.
- Free, no sign-up
- Follows the official RFC 9562 standard
Need more? Make them in bulkGenerate Nano ID in bulk
Make up to 10,000 Nano IDs at once and save them as a file. Three quick steps.
Enter a number from 1 to 10,000.
What is a Nano ID?
A Nano ID is a short random ID, 21 characters by default, made only of characters that are safe to use in URLs.
Nano ID is a small open-source library, not a formal standard. By default it picks 21 characters from a 64-character alphabet: A to Z, a to z, 0 to 9, underscore and hyphen. Each character carries 6 random bits, so a default ID has 126 bits of randomness, a little more than the 122 in a UUID v4.
It packs that into 21 characters instead of 36, and needs no encoding in links. You can pick a shorter length or a different alphabet, but every change to either one changes how likely a repeat is.
What a Nano ID looks like
Here is the ID you just made. ClickTap Generate above and watch it change.
- Every character is random. There is no version digit, no time and no fixed layout. With the default alphabet, each one adds 6 bits.
When to use Nano ID
Good for
- Short IDs in links, like /p/V1StGXR8_Z5jdHi6B-myT
- Public IDs for posts, files and invites
- Keys in front-end state and DOM elements
- Codes in your own alphabet, like hex or numbers only
How short can a Nano ID be?
Shorter IDs are easier to read, but they repeat sooner. These figures use the default URL-safe alphabet. Check your length against how many IDs you will ever make.
Make a Nano ID in code
import { nanoid } from 'nanoid';
const id = nanoid(); // 21 characters
const short = nanoid(10); // 10 characters
console.log(id, short);Uses the nanoid package from npm. Current versions are ESM only, so use import, not require().
import { customAlphabet } from 'nanoid';
const hexId = customAlphabet('0123456789abcdef', 12);
console.log(hexId()); // like 4f90d13a42bccustomAlphabet takes the characters and a default length, and returns a function.
from nanoid import generate
id = generate() # 21 characters
hex_id = generate('0123456789abcdef', 12) # alphabet, then length
print(id, hex_id)Uses the nanoid package from PyPI (pip install nanoid).
import gonanoid "github.com/matoous/go-nanoid/v2"
id, err := gonanoid.New()
if err != nil {
log.Fatal(err)
}
fmt.Println(id)Uses the go-nanoid package, listed in the official Nano ID docs.
use nanoid::nanoid;
let id = nanoid!();
let short = nanoid!(10);
println!("{id} {short}");Uses the nanoid crate, listed in the official Nano ID docs.
Nano ID vs UUID v4, ULID and UUID v7
Questions people ask
Is a Nano ID as unique as a UUID?
At the default 21 characters, yes. It has 126 random bits against 122 in a UUID v4, so a repeat is even less likely. Shorter lengths or smaller alphabets lower that number quickly.
Can I store a Nano ID in a UUID column?
No. A UUID column only takes 128-bit UUIDs. Store Nano IDs in a text column, such as varchar(21) or char(21). If the column must be a UUID, use UUID v4 instead.
Can I change a Nano ID to uppercase?
No. Nano IDs are case-sensitive. "abc" and "ABC" are different IDs, so changing the case would change the ID. To get only one case, pick the "Lowercase and numbers" alphabet.
How do I pick a safe length?
Work out how many IDs you will ever make, then pick a length where a repeat stays very unlikely. Each character you remove makes a repeat much more likely. Our collision probability guide shows the maths.


