badge

nanoid

Generate compact, URL-safe unique identifiers using a cryptographically secure random source. Customize length, alphabet, and optional prefixes/suffixes.

Generator

Client-side generation via `crypto.getRandomValues()`.

Recommended: 21 (nanoid default).

Alphabet size affects entropy and collision probability.

Description

`nanoid` produces compact identifiers designed for URLs and modern databases. It’s a practical alternative to UUIDs when you want shorter IDs while still keeping collision risk extremely low.

  • Choose a preset alphabet or provide your own.
  • Adjust the length to trade off readability vs. collision resistance.
  • Add a prefix/suffix for namespacing (e.g. `user_`, `order_`, `dev_`).
  • Runs fully in the browser; nothing is sent to any server.