Random NanoID Generator
Generate tiny, secure, URL-friendly, unique string IDs.
Configuration
Single NanoID
Click generate to start
Bulk Generation
Batch ModeAbout NanoID Generator
If your priority is short IDs that are easy to
paste into URLs and logs but still offer strong collision resistance,
NanoID is a great fit. NanoID is designed for
JavaScript and produces URL-friendly IDs using
a safe alphabet like A-Za-z0-9_-, which packs
lots of randomness into fewer characters.
Why NanoID is popular
- Short by default: NanoID’s default length is 21 characters, chosen to reach collision resistance comparable to UUID v4 while being much shorter.
- Strong randomness: It uses Node’s
cryptoand the browser Web Crypto API, avoidingMath.random()for secure usage. - Customizable: You can tune length, and even define a custom alphabet to match your product’s constraints (e.g., lowercase-only slugs, hex IDs, no ambiguous characters).
JavaScript / TypeScript examples
Basic usage:
import { nanoid } from "nanoid";
const id: string = nanoid(); // e.g. "V1StGXR8_Z5jdHi6B-myT"
const short: string = nanoid(10); // shorter => higher collision risk
console.log({ id, short }); Custom alphabet + size (great for “slug IDs”):
import { customAlphabet } from "nanoid";
// hex-ish IDs, 10 chars
const makeHexId = customAlphabet("1234567890abcdef", 10);
const orderId: string = makeHexId(); // e.g. "4f90d13a42"
console.log(orderId); When NanoID is the best choice
- Public URLs (invite links, short resources, share links)
- Client-generated IDs (optimistic UI, offline drafts)
- Distributed systems where shortness matters (logs, analytics events)
Need a compact random number generator or random generator for URLs? This NanoID tool serves as a configurable random object generator, creating URL-safe, unique strings. It beats a generic google random number generator or random nr tool by offering cryptographically strong, collision-resistant identifiers customizable to your needs.