Skip to content
LocalOnly

Nano ID Generator

New

Create compact, URL-safe Nano IDs with a custom size and alphabet.

Everything is processed locally in your browser

About Nano ID Generator

Nano ID is a tiny, secure, URL-friendly unique string generator - a modern alternative to UUID that produces shorter IDs by default. Generate IDs at the standard 21-character length or dial in your own size and alphabet, and watch the built-in collision estimate update as you go. All generation happens locally in your browser.

Features

  • Default 21-character IDs using the standard URL-safe alphabet
  • Custom size - trade shorter IDs for a lower collision margin
  • Custom alphabet, including numeric-only, lowercase, or no-look-alike sets
  • Live collision-probability estimate for your chosen size and alphabet
  • Unbiased character selection powered by crypto.getRandomValues
  • Bulk generation with one-click copy of the full list

How to use Nano ID Generator

  1. 1

    Choose a size

    Start with the default 21 characters, or reduce it for shorter IDs. The tool shows how the collision risk changes as you shrink the size.

  2. 2

    Set the alphabet (optional)

    Keep the default URL-safe set (A–Z, a–z, 0–9, _ and -), or supply your own - for example, digits only or a set that omits ambiguous characters like 0, O, I and l.

  3. 3

    Generate in bulk

    Enter how many IDs you need and generate them instantly. Each value is unbiased across your alphabet.

  4. 4

    Copy the results

    Copy one ID or the entire list, then drop them into URLs, database rows, or configuration.

Examples

A default Nano ID

21 characters from the standard URL-safe alphabet.

Input

Size: 21 · Alphabet: A-Za-z0-9_-

Output

V1StGXR8_Z5jdHi6B-myT

A short, digits-only code

A custom alphabet and smaller size for a human-friendly code.

Input

Size: 8 · Alphabet: 0123456789

Output

48310297

How Nano IDs work

Same safety, fewer characters

A default Nano ID is 21 characters from a 64-symbol alphabet, giving 126 bits of entropy - slightly more than a version 4 UUID's 122, in 21 characters instead of 36. The saving comes from the encoding rather than from any compromise in randomness. A UUID writes 128 bits as hexadecimal, which packs only 4 bits per character, and then adds four hyphens. Nano ID uses a 64-symbol alphabet at 6 bits per character and no separators.

Where that matters is anywhere identifiers are visible or repeated. A 40% shorter identifier makes URLs more manageable, fits more comfortably in fixed-width UI, and reduces bytes across every index and log line at scale. For an identifier a user might read aloud or type, the difference is more than cosmetic.

Choosing the alphabet is the real decision

The default alphabet is `A-Za-z0-9_-`, chosen to be URL-safe without percent-encoding. Both `_` and `-` are unreserved in RFC 3986, so an ID can sit in a path or a query string untouched.

The variant worth knowing about is the no-look-alikes alphabet, which removes characters that are easily confused - `0` and `O`, `1`, `l` and `I` - and also strips vowels to avoid generating real words, which matters more than people expect for user-facing codes. Use it for anything a human will read from a screen, copy from a printed page, or dictate over the phone. The cost is fewer symbols per character, so you need a longer ID for the same entropy.

Numbers-only alphabets are sometimes requested for legacy systems that cannot store letters. They work, but the entropy per character drops to about 3.3 bits, so a numeric ID needs roughly twice the length of the default to be equally safe. Check the length rather than assuming the default is still adequate.

Picking a length

The right length depends on how many identifiers you will generate and how badly a collision would hurt. At 21 characters with the default alphabet, you would need to generate a billion IDs per second for about 1,700 years to reach a 1% collision probability - comfortably beyond any application's needs.

Shortening is reasonable when volumes are small and a collision is recoverable. Ten characters gives 60 bits, which is fine for a few million records where the database has a unique constraint to catch the rare duplicate. Going below eight is where it gets risky, and the failure is silent unless you have that constraint.

The rule worth following is to keep a unique index on the column regardless of length. It costs nothing and turns an unlikely, hard-to-diagnose data corruption into an ordinary insert error that you can retry.

Reference

Length, entropy and collision risk

Using the default 64-character alphabet. Collision figures are the point of 1% probability.

LengthEntropy1% collision afterSuitable for
848 bits~2.4 million IDsShort-lived codes with a unique constraint
1272 bits~10 billion IDsInternal identifiers at moderate scale
1696 bits~4 × 10^14 IDsPublic identifiers
21 (default)126 bits~10^18 IDsAnything; the recommended default
32192 bitsBeyond practical boundsWhen 21 is not reassuring enough

Which tool should you use?

These tasks overlap. Here is how to pick the right one for what you are actually doing.

You need a compact identifier for a URL
Nano ID is the better fit. It is URL-safe by default and 40% shorter than a UUID.
A person will read, type or dictate the identifier
Use the no-look-alikes alphabet, which removes confusable characters and avoids forming real words.
You need a database primary key that sorts by creation time
A UUID version 7 is better - Nano IDs are fully random and carry no ordering.
An external system expects the UUID format
Use the UUID Generator. Nano IDs are not RFC-compliant UUIDs and will fail format validation.
You need a secret rather than an identifier
Use the Password Generator. Identifiers appear in logs and URLs by design.

Use cases

  • Short IDs for public URLs, share links, and slugs
  • Database identifiers where a compact key is preferable to a full UUID
  • Coupon, invite, and referral codes with a readable custom alphabet
  • Filenames and object keys that must be URL-safe
  • Client-generated keys for optimistic UI updates

Troubleshooting common errors

IDs contain characters that break a URL or a filename

Why: A custom alphabet including characters that are reserved in URLs or forbidden in filenames.

Fix: Stick to the default `A-Za-z0-9_-`, which is safe in both contexts.

Users mistype identifiers when reading them out

Why: The default alphabet contains confusable characters - 0 and O, 1 and l and I.

Fix: Switch to the no-look-alikes alphabet and lengthen the ID slightly to compensate for the smaller symbol set.

An ID spelled out an unfortunate word

Why: Random selection from an alphabet containing vowels will occasionally produce real words.

Fix: Use the no-look-alikes alphabet, which excludes vowels for this reason.

Collisions occurred sooner than expected

Why: Either the length was too short for the volume, or the alphabet was smaller than assumed - numeric alphabets need roughly double the length.

Fix: Recompute entropy as length × log2(alphabet size), and keep a unique index so duplicates surface as errors rather than corruption.

Limitations

What this tool deliberately does not do, so you know when to reach for something else.

  • Nano IDs are not UUIDs and will fail UUID format validation.
  • They are fully random, so they carry no timestamp and cannot be sorted chronologically.
  • A custom alphabet changes the entropy per character; length must be recalculated to match.
  • An identifier is not a secret and should never be used as an authorisation token.
  • Case sensitivity means they are unsuitable for case-insensitive systems such as some filesystems.

Frequently asked questions

Learn more

Command Palette

Search for a tool or command