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

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.

How to use it

  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

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.

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

  • 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