Small, URL-friendly IDs
Nano ID is a popular format for random string IDs. The default is 21 characters from a 64-symbol URL-safe alphabet (A-Z, a-z, 0-9, underscore and hyphen), which gives 126 random bits, slightly more than a UUID v4, in a shorter string.
Shorter IDs are fine when you have fewer items. Use the length slider to trade length for collision resistance, and pick the lowercase or hex alphabet for systems that ignore letter case.
Picking a length
- 21 characters: the default, safe for virtually any number of IDs.
- 12 to 16 characters: fine for short links or invite codes in a mid-sized app, with a uniqueness check.
- 8 characters or fewer: only with a database uniqueness check, since collisions become likely at scale.
Frequently asked questions
Can I use Nano IDs as secrets?
At 21 characters they have enough randomness to work as tokens, but treat them like any secret: store a hash and keep them out of URLs that get logged.
Are these compatible with the nanoid library?
Yes. The default alphabet and length match the nanoid package, so these IDs look exactly like the ones it creates.