# nanoid

> A tiny (118 bytes), secure URL-friendly unique string ID generator

Latest version **6.0.1** (published 2026-08-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install nanoid
pnpm add nanoid
yarn add nanoid
bun add nanoid
```

Provides the command `nanoid`.

## Health

**Score 75/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score; popular repo.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 6.0.1 |
| Published | 2026-08-03 |
| First published | 2017-08-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^22 \|\| ^24 \|\| >=26 |
| Dependencies | 0 |
| Unpacked size | 14.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 26967 |
| Author | Andrey Sitnik |
| Maintainers | ai |
| Keywords | id, random, url, uuid |

## Links

- npm: https://www.npmjs.com/package/nanoid
- Repository: https://github.com/ai/nanoid
- Homepage: https://github.com/ai/nanoid#readme
- Issues: https://github.com/ai/nanoid/issues
- Funding: https://github.com/sponsors/ai
- npm.io page: https://npm.io/package/nanoid

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 6.0.1 (latest) — 2026-08-03
- 3.3.19 (legacy) — 2026-09-10
- 3.3.18 — 2026-08-07
- 3.3.17 — 2026-08-03
- 6.0.0 — 2026-07-12
- 3.3.16 — 2026-07-12
- 5.1.16 — 2026-06-24
- 3.3.15 — 2026-06-21
- 5.1.15 — 2026-06-20
- 3.3.14 — 2026-06-20
- 5.1.14 — 2026-06-18
- 5.1.13 — 2026-06-18
- 5.1.12 — 2026-06-18
- 3.3.13 — 2026-06-18
- 5.1.11 — 2026-04-30
- … 118 more at https://npm.io/package/nanoid/versions

## README

# Nano ID

<img src="https://ai.github.io/nanoid/logo.svg" align="right"
     alt="Nano ID logo by Anton Lovchikov" width="180" height="94">

**English** | [日本語](./README.ja.md) | [Русский](./README.ru.md) | [简体中文](./README.zh-CN.md) | [Bahasa Indonesia](./README.id-ID.md) | [한국어](./README.ko.md) | [العربية](./README.ar.md)

A tiny, secure, URL-friendly, unique string ID generator for JavaScript.

> “An amazing level of senseless perfectionism,
> which is simply impossible not to respect.”

- **Small.** 118 bytes (minified and brotlied). No dependencies.
  [Size Limit] controls the size.
- **Fast.** 50% faster than native `crypto.randomUUID()`.
- **Safe.** It uses hardware random generator. Can be used in clusters.
- **Short IDs.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`).
  So ID size was reduced from 36 to 21 symbols.
- **Portable.** Nano ID was ported
  to over [20 programming languages](./README.md#other-programming-languages).

```js
import { nanoid } from 'nanoid'
model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
```

---

<img src="https://cdn.evilmartians.com/badges/logo-no-label.svg" alt="" width="22" height="16" />  Nano ID is built by <b><a href="https://evilmartians.com/">Evil Martians</a></b>, an American design and engineering consultancy for <b>developer tools, AI, and cybersecurity startups</b>.

---

[Size Limit]: https://github.com/ai/size-limit

## Docs
Read full docs **[here](https://github.com/ai/nanoid#readme)**.

---
_Source: https://npm.io/package/nanoid · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
