Title here
Summary here
NanoID is a tiny, secure, URL-friendly unique string ID generator. It’s similar to UUID v4 but is much more compact while still maintaining excellent uniqueness guarantees. NanoIDs are typically 21 characters long by default (though this is configurable) and use a URL-friendly character set.
Benefits of NanoIDs:
A standard NanoID uses a 64-character URL-safe alphabet (A–Z, a–z, 0–9, _, -), packing 6 bits of cryptographic randomness per character:
nanoid library, which draws on the operating system’s cryptographically secure random generator rather than Math.random(), so they are unguessable and safe for public URLs, share links, and invite codes.| Dimension | NanoID (21 chars) | UUIDv4 (36 chars) | XID (20 chars) |
|---|---|---|---|
| Random entropy | 126 bits | 122 bits | Non-random (timestamp + node + counter) |
| URL-safe (no escaping) | Yes (A-Za-z0-9_-) |
Yes (with hyphens) | Yes (0-9a-v, lowercase only) |
| Time-sortable? | No (purely random) | No (purely random) | Yes (1-second chronological order) |
| Customizable alphabet/length | Yes (e.g., no lookalike chars 0OIl) |
Fixed RFC 9562 format | Fixed 12-byte format |
| Best for | Short public URLs, slugs, invite tokens, frontend IDs | Legacy DBs with native UUID column |
High-write DB primary keys & distributed logs |
nanoid README). Note that the default alphabet includes - and _, so double-clicking an ID may select only part of it; use a custom alphabet without them if that matters.A–Z, lowercase a–z, digits 0–9, underscore _, and hyphen -. No URL percent-encoding is ever needed.