>_
smartdevbox
Open SmartDevBox — free, no sign-up97+ tools · 100% client-side · no account required

Nano ID Generator — Generate Compact URL-Safe IDs Online

Nano ID Generator creates short, URL-safe unique identifiers using a cryptographically random alphabet of 64 characters (A–Z, a–z, 0–9, _, -). The default size of 21 characters gives the same collision probability as UUID v4 (126 bits of randomness). Nano IDs are smaller than UUIDs (21 vs 36 characters), URL-safe without encoding, and widely used in JavaScript and TypeScript backends. All generation runs in the browser using the Web Crypto API.

Nano ID vs UUID vs ULID

UUID v4 is the most portable format: 32 hex digits in 8-4-4-4-12 groups (xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx). It is natively supported in PostgreSQL, MySQL, and most ORMs. The hyphenated format is 36 characters; without hyphens it is 32. The 4 and y prefix digits are version/variant markers, leaving 122 bits of actual randomness.

ULID (Universally Unique Lexicographically Sortable Identifier) encodes a 48-bit millisecond timestamp in the first 10 characters and 80 random bits in the remaining 16 characters. ULIDs sort chronologically in string order, making them useful for time-series data in systems that sort by primary key (e.g. DynamoDB). They use the Crockford Base32 alphabet (uppercase, no ambiguous characters like I, L, O, U).

Nano ID uses 64 URL-safe characters to pack more entropy per character than hex or Base32. At 21 characters it matches UUID v4's collision resistance while being 42% shorter. It has no timestamp component, so it does not sort chronologically — use ULID if ordered IDs matter. Nano ID is the best choice when you need short, dense, URL-safe identifiers for database keys, links, and slugs.

Collision Probability

The collision probability for N generated IDs of size S over an alphabet of A characters is approximately N² / (2 × A^S). For the default 21-character Nano ID (A=64): to reach a 1% collision probability you would need to generate 2.71 × 10^18 IDs — roughly 2.7 quintillion. At a rate of one million IDs per second, that would take about 86,000 years.

If you need shorter IDs (say, 12 characters for a URL slug), the collision probability rises significantly. At 12 characters (A=64): a 1% collision threshold is reached at ~3.9 × 10^10 IDs (~39 billion). For most applications this is still more than sufficient, but for extremely high-volume systems or globally shared namespaces, use the default 21 characters.

Common Use Cases

  • Generating short unique IDs for database primary keys
  • Creating URL-safe identifiers for shareable links and slugs
  • Generating short session or token IDs for web applications
  • Creating unique filenames for user-uploaded content
  • Replacing UUID v4 with a more compact identifier format

Frequently Asked Questions

What is a Nano ID?

Nano ID is a compact, URL-safe unique identifier. The default 21-character Nano ID uses 64 possible characters (A–Z, a–z, 0–9, _, -), giving 64^21 ≈ 2^126 possible values — the same collision probability as UUID v4. It was created by Andrey Sitnik and is widely used in the JavaScript/TypeScript ecosystem.

How does Nano ID compare to UUID v4?

Both have the same collision probability (~2^122 for UUID v4, ~2^126 for 21-character Nano ID). Nano ID is shorter (21 vs 36 characters), URL-safe without encoding (no hyphens that need to be escaped), and has a simpler structure. UUID v4 is more universally supported in databases and tools.

Can I use a custom alphabet with Nano ID?

Yes. SmartDevBox allows you to set a custom alphabet. You can restrict to alphanumeric-only (no _ or -), use only lowercase, or use any set of characters. Longer alphabets with the same size produce more entropy; shorter alphabets require a longer size for the same collision probability.

Is Nano ID cryptographically random?

Yes. SmartDevBox uses crypto.getRandomValues() (the Web Crypto API) to generate random bytes, which is cryptographically secure. The bytes are mapped to the alphabet using rejection sampling to avoid modulo bias.

Privacy & Security

This tool runs entirely in your browser using client-side JavaScript. No data is sent to a server — your input never leaves your machine. SmartDevBox has no account system, no usage tracking, and no paid tier. See the Privacy & Security page for full details.

  • UUID GeneratorGenerate cryptographically random UUID v4 identifiers instantly. Bulk generation supported. Free, no sign-up, 100% client-side.
  • ULID GeneratorGenerate Universally Unique Lexicographically Sortable Identifiers (ULIDs). Free, no sign-up, 100% client-side.
  • Random String GeneratorGenerate random strings with configurable length and character set. Free, no sign-up, 100% client-side.
  • Password GeneratorGenerate strong random passwords with configurable length, uppercase, digits, and symbols. Free, no sign-up.