Nano ID Generator & Validator

Generate cryptographically secure, URL-safe Nano IDs with configurable length and alphabets. Validate existing Nano IDs, analyze entropy, and download results as TXT, CSV, or JSON. 100% client-side.

Loading Nano ID Generator & Validator workspace...

What is Nano ID?

Nano ID is a modern, cryptographically secure unique identifier generator originally created by Andrey Sitnik. It produces compact, URL-safe random strings designed as a practical replacement for UUID v4 in modern applications. At just 21 characters by default (versus UUID's 36), Nano ID achieves equivalent collision resistance in a significantly smaller footprint.

Unlike UUID, which has a fixed format and hexadecimal character set, Nano ID supports fully configurable lengths and alphabets, making it ideal for everything from database primary keys to short user-facing invite codes, API tokens, and URL slugs.

Nano ID vs UUID — Why Shorter is Better

FeatureNano IDUUID v4
Default Length21 characters36 characters (32 hex + 4 hyphens)
Default Alphabet64 URL-safe chars16 hex chars (0–9, a–f)
Entropy Bits~126 bits122 bits
URL-Safe (no encoding)✅ Yes✅ Yes (no hyphens)
Custom Alphabet✅ Fully configurable❌ Fixed hexadecimal
Custom Length✅ 1–255 chars❌ Always 32/36 chars
Random Sourcecrypto.getRandomValuescrypto.getRandomValues
Bundle Size~130 bytes (gzip)~4KB (uuid library)
Sortable (chronological)❌ Random❌ Random (v4)

When storage and bandwidth efficiency matter — such as in URLs, QR codes, or database fields with tight size constraints — Nano ID's shorter default output provides meaningful savings at scale without sacrificing security.

Alphabet Presets — Choosing the Right Character Set

The alphabet determines which characters appear in generated IDs. A larger alphabet means more entropy per character, allowing shorter IDs to achieve the same collision resistance. ToolZeno includes 8 built-in presets:

Default (Nano ID)

Characters: A–Z, a–z, 0–9, _, - (64 chars)

Best for: General purpose IDs, database keys, API tokens

URL-Safe Base64

Characters: A–Z, a–z, 0–9, -, _ (64 chars)

Best for: URL parameters, OAuth tokens, JWT-style identifiers

Alphanumeric

Characters: A–Z, a–z, 0–9 (62 chars)

Best for: File names, IDs without special characters

Uppercase + Digits

Characters: A–Z, 0–9 (36 chars)

Best for: Human-readable codes, voucher codes, license keys

Lowercase + Digits

Characters: a–z, 0–9 (36 chars)

Best for: Case-insensitive URLs, subdomain identifiers

Numbers Only

Characters: 0–9 (10 chars)

Best for: Numeric OTPs, PINs, order numbers (low volume only)

Nano ID Length Recommendations

The appropriate length depends on your expected generation volume and required security level. Entropy scales linearly with length — each additional character multiplies the uniqueness space by the alphabet size:

8 chars~48 bits
Short-lived session codes, in-memory references, low-volume use cases— Not recommended for high-volume production systems.
12 chars~72 bits
Invite links, coupon codes, short URL slugs (moderate volume)
21 chars (default)~126 bits
Primary keys, API tokens, session IDs — equivalent to UUID v4
32 chars~192 bits
High-security tokens, webhook secrets, critical identifiers
64 chars~384 bits
Master secret keys, long-lived API keys, cryptographic identifiers

Common Use Cases for Nano ID

  • Database Primary Keys — Short, URL-safe primary keys for PostgreSQL, MySQL, MongoDB, or SQLite records (faster to index than UUID with Btree than random UUID v4).
  • Session Tokens — Secure, random session identifiers stored in cookies or headers for web authentication flows.
  • Short URLs — Compact 8–10 character ID codes for URL shorteners that appear in shareable links (e.g. app.com/r/Zq3r_8Kp).
  • File Uploads — Rename uploaded files with unique Nano IDs to prevent filename collisions and path traversal vulnerabilities.
  • Invite & Referral Codes — Generate uppercase-only, human-readable codes like XZQK73A9 for one-time invitations and referral programs.
  • Idempotency Keys — Prevent duplicate API request processing by attaching a unique Nano ID to each outgoing request as an idempotency key.
  • React / Frontend Component Keys — Dynamic list rendering keys when data lacks natural unique identifiers.
  • API Keys & Tokens — Generate long (32–64 char) Nano IDs for API authentication credentials, replacing manual random string generation.

Security Considerations

ToolZeno Local Browser Execution Guarantee

Every Nano ID generated by ToolZeno is computed entirely within your browser using the Web Crypto API (crypto.getRandomValues). No generated IDs, custom alphabets, or validator inputs are ever transmitted to our servers. This makes ToolZeno safe to use even for generating production API keys, session tokens, and secret values.

Important note on predictability: Even with cryptographic randomness, the security of a Nano ID depends on its entropy (length × log₂ of alphabet size). An 8-character numeric-only Nano ID has only 26.6 bits of entropy — far too low for authentication tokens or security-sensitive identifiers. Always use at least 21 characters with the default or URL-safe alphabet for security purposes.

How to Use the Nano ID Generator

  1. Choose an Alphabet / Character Set from the dropdown (or select "Custom Alphabet" to type your own characters).
  2. Set the ID Length using the slider or input field. Click a preset (8, 16, 21, 32, 64) for common values.
  3. Set the generation Quantity from 1 to 10,000 using the slider, input field, or preset buttons.
  4. Click Generate Nano IDs (or press Ctrl+Alt+G).
  5. Review telemetry stats (count, length, payload size, time taken) and entropy analysis (alphabet size, entropy bits, collision threshold).
  6. Copy individual IDs by hovering a row and clicking the copy icon. Use Copy All or download as TXT / CSV / JSON.
  7. To validate an existing Nano ID, switch to the Nano ID Validator tab, paste your ID, select the reference alphabet, and review the validation report.

Frequently Asked Questions

Nano ID is a tiny (130 bytes), modern, URL-safe unique identifier library designed as a faster and more compact alternative to UUID. While UUID v4 always produces a 36-character hexadecimal string (32 hex digits + 4 hyphens), Nano ID defaults to 21 characters using a 64-character URL-safe alphabet. This gives it a smaller footprint while maintaining equivalent or superior collision resistance. UUID v4 has 122 bits of randomness; a 21-character Nano ID with the default alphabet provides ~126 bits.

Yes. The official Nano ID implementation uses the CSPRNG (Cryptographically Secure Pseudo-Random Number Generator) available in each runtime. In browsers, this is the Web Crypto API's `crypto.getRandomValues()` function, which is backed by OS-level entropy sources. ToolZeno's generator uses the official `nanoid` package's `customAlphabet` function, which internally calls `crypto.getRandomValues`, making every generated ID cryptographically random and safe for use as session tokens, database keys, and API identifiers.

The default length of 21 characters with the 64-character alphabet is carefully chosen to be equivalent in collision resistance to UUID v4. For most use cases — database primary keys, session tokens, URL slugs — 21 characters is the recommended length. If you need shorter IDs for user-visible codes (such as invite links), 8–12 characters are workable for low-volume systems. For high-security secrets, API keys, or tokens, 32–64 characters provides overwhelming uniqueness well beyond any practical collision risk.

With the default 21-character length and 64-character alphabet, you would need to generate approximately 17 billion IDs before reaching a 1% probability of any collision occurring (the birthday problem). For comparison, UUID v4 reaches this threshold at a similar scale. If your system generates thousands of IDs per second, you won't encounter statistical collision issues even over decades of operation. For higher volumes, simply increasing the length provides exponentially more headroom.

Yes. One of Nano ID's key advantages over UUID is full alphabet customization. You can use any set of unique characters as your alphabet — for example, uppercase-only letters for human-readable codes, numeric-only for PIN codes, or a custom character set that excludes visually ambiguous characters (like O vs 0, l vs 1). The critical constraint is that every character in your custom alphabet must be unique — duplicates would skew the randomness distribution and reduce effective entropy. ToolZeno validates your custom alphabet in real time.

Nano ID defaults to the URL-safe character set (`A-Za-z0-9_-`) to allow IDs to be used directly in URLs, file names, database keys, and HTML attributes without any encoding or escaping. UUID uses hexadecimal (0-9, a-f) which is also URL-safe, but its 36-character string is nearly twice as long as a Nano ID. The URL-safe Nano ID gives you shorter, more compact IDs that still work everywhere a UUID would.

ToolZeno supports bulk generation from 1 to 10,000 Nano IDs in a single click. The workspace automatically optimizes view modes: for small batches (<= 150), an interactive list with individual copy and search is shown; for larger batches, a high-performance raw text area is used for smooth browser rendering. All 10,000 IDs are generated in a single pass using a pre-compiled nanoid factory, typically completing in under 100ms on modern hardware.