NanoID Generator

Generate compact, URL-safe unique IDs instantly

Free NanoID generator to create short, URL-safe unique IDs. Pick a size and alphabet, generate a single ID or a batch, and copy with one click. 100% client-side, your data never leaves your browser.

Generating…

NanoID at a glance

Default NanoID

Length21 characters
AlphabetURL-safe (A-Za-z0-9_-)
Entropy~126 bits
URL-safeYes, no encoding needed
SortableNo (random like UUID v4)

NanoID vs UUID vs ULID

LengthNanoID 21, UUID 36, ULID 26
URL-safeNanoID and ULID yes
SortableOnly ULID and UUID v7
Custom sizeNanoID yes
StandardUUID RFC 9562, others community

NanoID Guide

What is a NanoID?

NanoID is a small unique identifier designed to be shorter than a UUID and safe in URLs. The default is 21 characters from a 64-character alphabet: uppercase, lowercase, digits, _, and -. That is about 126 bits of entropy, which is enough uniqueness for almost any app without the hyphens and hex padding of a UUID.

The format comes from the nanoid library. This generator uses the same unbiased sampling idea and crypto.getRandomValues() in your browser.

Size and alphabet

Collision resistance is alphabet size ^ length. Shorten the ID only when you know the volume you will mint. A 12-character URL-safe ID is fine for a small product catalog. A 6-character numeric code is not enough for a public signup token.

  • URL-safe (default): Best for public IDs in links and filenames.
  • No lookalikes: Drops 0/O, 1/l/I and similar pairs so humans can read the ID aloud.
  • Numbers or hex: Use when the consumer only accepts digits or hex.

NanoID vs UUID vs ULID

  • Use NanoID for short public slugs, invite codes, and API IDs where URL safety and length matter.
  • Use UUID v4 or v7 when you need the RFC 9562 format or a native uuid column. Generate those with the UUID Generator.
  • Use ULID when the ID should sort by time as a string. Generate those with the ULID Generator.

NanoIDs are random, so they behave like UUID v4 in B-tree indexes. If you need time-ordered primary keys, pick UUID v7, ULID, or a KSUID.

NanoID Generator FAQ

What is a NanoID?

A NanoID is a compact unique identifier. The default is 21 URL-safe characters from a 64-character alphabet. It is shorter than a UUID and needs no encoding in URLs, filenames, or HTML.

How do I generate a NanoID online?

This page generates one as soon as it loads. Click Generate for a new ID, adjust size or alphabet if you need a shorter or numeric value, then copy it. Bulk Generate creates up to 100 IDs at once.

What is the difference between NanoID and UUID?

A default NanoID is 21 characters and URL-safe. A UUID is 36 characters with hyphens and a fixed hex layout from RFC 9562. NanoID lets you change size and alphabet. UUID is the better choice when you need a standard type in PostgreSQL or SQL Server.

Is NanoID unique enough?

A 21-character URL-safe NanoID has about 126 bits of entropy. Collisions are not a practical concern at that size. The hint under the generated ID shows when a 1% collision chance appears for the size and alphabet you selected.

Can I use NanoIDs as database primary keys?

Yes if uniqueness is all you need. They are random, so they scatter B-tree inserts the same way UUID v4 does. For write-heavy tables, prefer UUID v7 or ULID.

What alphabet does NanoID use?

The default is 64 URL-safe characters: A-Za-z0-9_-. This tool also offers alphanumeric, numbers, hex, and a no-lookalikes set. Custom alphabets need at least two unique characters. Duplicate characters are ignored.

Is it safe to generate NanoIDs in the browser?

Yes. Generation uses crypto.getRandomValues() and unbiased masking so every alphabet character is equally likely. All work stays in your browser.