NanoID nanoid · URL-safe
A compact identifier of URL-safe characters, 21 characters by default.
Overview
It picks characters at random from the A-Za-z0-9_- alphabet. It is shorter than a UUID yet has a low collision probability, and its alphabet and length can be customized.
Structure
| Bit length | ~126 |
|---|---|
| Character length | 21 |
| Format | URL-safe A-Za-z0-9_- |
| Sortable | No |
| Random-based | Yes |
When to use
Great where length matters, such as short links, public IDs, and coupon codes. A good choice when sorting is unnecessary and conciseness comes first.