ID generators

Nano ID (nanoid) Generator and Collision Calculator

Create short, URL-safe random IDs with nanoid's unbiased algorithm, pick any alphabet and length, and see exactly how long they stay collision-free at your scale.

  • Free foreverNo trial, no paywall, no usage limits.
  • No sign-upOpen the page and start. We never ask for an email to use a tool.
  • PrivateEverything runs in your browser. Your input is never uploaded or stored on our servers.
  • Works offlineOnce the page has loaded, the tool keeps working without a connection.
The characters an ID can contain. A bigger alphabet packs more randomness into each character, so IDs can be shorter for the same collision safety.
Nanoid's default: A–Z, a–z, 0–9, _ and - (64 symbols). Safe in URLs, file names and HTML attributes without escaping.A–Z, a–z and 0–9 (62 symbols). No punctuation, so IDs select with a double-click.a–z and 0–9 (36 symbols). For case-insensitive places: DNS labels, some file systems, email local parts.0–9 only (10 symbols). For numeric codes; needs many more characters for the same safety.0–9 and a–f (16 symbols). Each character is exactly 4 bits, e.g. 32 characters = 128 bits.36 symbols without 1/l/I, 0/O/o, 5/S, 2/Z, u/v and vowels — for codes people read aloud or type from paper, and no accidental words.Your own alphabet. Duplicates are removed so every symbol stays equally likely.
How many characters each ID has. Nanoid's default of 21 URL-safe characters gives 126 random bits, slightly more than a UUID v4's 122.
21 characters

64 symbolsABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-

Your nanoid

126 bits
000000000000000000000

21 characters × 64 symbols = 126.0 bits of randomness (a UUID v4 has 122)

Batch

How many IDs to make and how the list is written.
Generate 1 to 1,000 IDs at once. All of them appear in the list below, ready to copy or download.
How the batch is joined: one per line for scripts, a JSON array for code and fixtures, a CSV column for spreadsheets, or a comma list to paste into SQL IN (…).
Wrap each ID in quotes, e.g. single quotes for SQL string literals. JSON arrays always use double quotes.
Double quotes, as JSON and most languages use.Single quotes, as SQL string literals use.
A single-key shortcut that works anywhere on the page except in text fields. Turn it off if you use speech input or keyboard tools that could press R by accident.

IDs

Every ID in the batch, formatted with your options. Copy them all or download a file.
Copy allDownload nanoids.txt

Collision probability calculator

Uses the birthday bound n ≈ √(2 · N · ln(1 / (1 − p))), where N is the number of possible IDs. It updates with the alphabet and size above.
Your expected peak rate across every server and client that creates these IDs.
The probability of at least one duplicate you are willing to accept. Nanoid's own calculator uses 1%.

Time until a 1% chance of a duplicate

Safe

~149 billion years

At 1,000 IDs per hour, you would need about 1.3 quintillion IDs before the chance of even one duplicate reaches 1%. Safe: a duplicate is practically impossible at this rate.

For comparison, a UUID v4 (122 random bits) at the same rate: ~37 billion years.

Need a secure web app built around this? Talk to our team

Quick answer

Nano ID (nanoid) is a small, popular library for short, random, URL-safe IDs. Its default is 21 characters from a 64-symbol alphabet (A–Z, a–z, 0–9, _ and -), which gives 126 random bits, slightly more than a UUID v4. In Playxoft's Nano ID generator, choose an alphabet and size to generate IDs in bulk with the same unbiased algorithm, then use the collision calculator to see how long they stay safe at your generation rate.

  • Unbiased generation
  • Six alphabet presets
  • Custom alphabets
  • Size from 2 to 64
  • Collision calculator
  • Bulk up to 1,000
  • Copy and download

How to use the Nanoid Generator

  1. 1Pick an Alphabet: URL-safe (the nanoid default), alphanumeric, lowercase, numbers, hex, no look-alikes, or your own Custom set.
  2. 2Drag Size to set how many characters each ID has. The bit count shows how much randomness that buys.
  3. 3Set How many IDs to generate and a list layout, then Copy all or Download them.
  4. 4In the Collision probability calculator, enter how many IDs you create per second, minute, hour or day.
  5. 5Read how long it takes before a duplicate becomes likely, and lengthen the ID if the tool marks it as risky.

What is Nano ID (nanoid)?

Nano ID, published as the nanoid package, is an open-source ID generator, first written for JavaScript and since ported to most languages. It produces short random strings like V1StGXR8_Z5jdHi6B-myT: by default 21 characters from a 64-symbol URL-safe alphabet (A–Z a–z 0–9 _ -).

Three properties made it popular:

  • Secure randomness. It reads from the operating system's cryptographic generator (crypto.getRandomValues in browsers), never Math.random().
  • Unbiased. Every symbol is exactly equally likely, even with alphabets whose size does not divide 256.
  • Compact. 21 characters carry 126 random bits, slightly more than the 122 in a UUID v4, in 15 fewer characters and with no hyphens.

This page implements the same algorithm in your browser, so the IDs are interchangeable with ones from the library. A nanoid is just a string: nothing else needs to know how it was made.

How does nanoid avoid modulo bias?

The obvious way to pick a symbol is alphabet[byte % alphabet.length]. With 62 symbols that is subtly wrong: 256 = 4 × 62 + 8, so the byte values 248–255 wrap around onto the first 8 symbols, making them 25% more likely than the rest (5 chances in 256 instead of 4). Biased IDs are easier to guess and collide sooner.

Nanoid masks each random byte to the smallest power of two that covers the alphabet (63 for 62 symbols) and throws away values that land outside it. It requests about 1.6 times as many bytes as it needs so one round is almost always enough:

function randomId(alphabet, size) {
  const mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1;
  const step = Math.ceil((1.6 * mask * size) / alphabet.length);
  let id = "";
  while (true) {
    const bytes = crypto.getRandomValues(new Uint8Array(step));
    for (const byte of bytes) {
      const symbol = alphabet[byte & mask]; // undefined when out of range
      if (symbol && (id += symbol).length === size) return id;
    }
  }
}

How likely is a nanoid collision?

A collision means generating the same ID twice. With N possible IDs, the birthday bound says you can create about √(2 · N · ln(1 / (1 − p))) IDs before the chance of any duplicate reaches p. For 21 URL-safe characters, N = 64^21 = 2^126, so a 1% risk takes about 1.3 quintillion IDs.

How size changes that with the URL-safe alphabet, from this page's calculator:

SizeRandom bitsIDs for a 1% chanceAt 1,000 IDs/hourAt 1,000 IDs/second
8482.4 million3.3 months40 minutes
1060152 million17 years1.8 days
12729.7 billion1,111 years3.7 months
169640 trillion4.6 million years1,265 years
21 (default)1261.3 quintillion149 billion years41 million years
UUID v4122327 quadrillion37 billion years10 million years

Every character you remove divides the safe number of IDs by 8 (the square root of 64). Short codes are fine for small, short-lived sets, but anything stored permanently should stay near the default, and the database column should still have a unique constraint.

Which alphabet should I choose?

A smaller alphabet carries fewer bits per character, so you need more characters for the same safety:

AlphabetSymbolsBits per characterCharacters for 126 bits
URL-safe (default)646.0021
Alphanumeric625.9522
Lowercase + digits365.1725
No look-alikes365.1725
Hex164.0032
Numbers103.3238
  • URL-safe is the best default for URLs, file names and database keys.
  • Alphanumeric avoids _ and -, so the whole ID selects with a double-click.
  • Lowercase suits case-insensitive systems such as DNS names.
  • No look-alikes suits codes that people read from paper or say over the phone.

Nanoid vs UUID: which should I use?

Both are random, secure identifiers; they differ in format and ecosystem:

Nanoid (default)UUID v4
ExampleV1StGXR8_Z5jdHi6B-myT919108f7-52d1-4320-9bac-f847db4148a8
Length21 characters36 characters
Random bits126122
StandardLibrary conventionRFC 9562
Native database typeNo (text column)Yes (uuid, 16 bytes)
Sortable by timeNoNo (use v7 or a ULID)

Use nanoid for IDs people see: short links, slugs, invite codes, client-side keys. Use a UUID when a database or API expects one, and a ULID or UUID v7 when you need time ordering.

How do I generate a nanoid in code?

// JavaScript — npm install nanoid (v5 is ESM-only; v3 also supports CommonJS)
import { nanoid, customAlphabet } from "nanoid";
nanoid();                                  // 21 URL-safe characters
customAlphabet("0123456789abcdef", 16)();  // 16 hex characters

# Python — pip install nanoid
from nanoid import generate
generate()                                 # 21 URL-safe characters
generate("0123456789abcdef", 16)

// Go — github.com/matoous/go-nanoid/v2
id, err := gonanoid.New()
hex, err := gonanoid.Generate("0123456789abcdef", 16)

// C# — dotnet add package Nanoid
using NanoidDotNet;
var id = Nanoid.Generate();
var hex = Nanoid.Generate("0123456789abcdef", 16);

Frequently asked questions

Yes, for identifiers. It uses the platform's cryptographically secure random generator and an unbiased selection algorithm, so IDs cannot be predicted from earlier ones. An unguessable ID is still not access control, so always check permissions on the server.
Yes. The default 21-character nanoid has 126 random bits, slightly more than the 122 in a UUID v4, yet it is 15 characters shorter because each character carries 6 bits instead of 4 and there are no hyphens.
In theory any random ID can. In practice it depends on length and volume: with the default settings you would need about 1.3 quintillion IDs for a 1% chance of one duplicate. Shorter IDs collide much sooner, which the collision calculator on this page shows for your rate.
No. Nanoids are entirely random, so their order means nothing. If you need IDs that sort by creation time, use a ULID or a UUID version 7, both of which start with a millisecond timestamp.
Yes. Choose Custom and type any characters, including emoji. Duplicates are removed automatically, because a repeated character would be picked more often. A smaller alphabet needs a longer ID for the same collision safety.
No. IDs are generated with your browser's crypto.getRandomValues and never leave your device. Nothing is uploaded, logged or stored, and the tool works offline once loaded.

Last updated by the Playxoft engineering team.

From the engineers who built this tool

Building something bigger than a quick fix?

Auth, payments, dashboards and security are where web apps get hard. We have shipped them many times. Share your idea and we will map out a realistic plan and estimate, free and with no obligation.

More free tools

See all tools

UUID Generator

Generate v4 and v7 UUIDs in bulk, and decode any UUID's version and timestamp.

Open tool

ULID Generator

Generate sortable ULIDs in bulk, decode their timestamps and convert them to UUIDs.

Open tool

JWT Decoder

Decode JWTs, explain every claim and expiry, verify signatures and sign new tokens.

Open tool

Base64 Encoder and Decoder

Encode text or files to Base64 and back, with Base64url, data URIs and type-detected downloads.

Open tool

URL Encoder and Decoder

Percent-encode or decode URLs and query values, and inspect every parameter.

Open tool

Hash Generator

MD5, SHA-1, SHA-256, SHA-384 and SHA-512 for text or files, with HMAC and checksum verify.

Open tool