# nanoid-dictionary

> Predefined character sets to use with nanoid

Latest version **5.0.0** (published 2025-04-26) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2025-04-26 |
| First published | 2018-07-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 147 |
| Author | Stanislav Lashmanov |
| Maintainers | cyberap |

## Links

- npm: https://www.npmjs.com/package/nanoid-dictionary
- Repository: https://github.com/CyberAP/nanoid-dictionary
- Issues: https://github.com/CyberAP/nanoid-dictionary/issues
- npm.io page: https://npm.io/package/nanoid-dictionary

## Recent versions

- 5.0.0 (latest) — 2025-04-26
- 5.0.0-beta.1 (beta) — 2021-05-05
- 4.3.0 — 2021-04-07
- 4.2.0 — 2021-01-16
- 4.1.0 — 2020-10-18
- 4.0.0 — 2020-10-18
- 3.0.0 — 2020-01-09
- 2.0.0 — 2018-12-22
- 1.1.0 — 2018-11-06
- 1.0.1 — 2018-07-05
- 1.0.0 — 2018-07-05

## README

# nanoid-dictionary
Predefined character sets to use with [nanoid](https://github.com/ai/nanoid). Used by [nanoid-generate](https://github.com/CyberAP/nanoid-generate).

[![npm](https://img.shields.io/npm/v/nanoid-dictionary)](https://www.npmjs.com/package/nanoid-dictionary)


## Install
Install nanoid and dictionary

`npm i nanoid nanoid-dictionary`

_Note_: If you plan on using `import` style ES6 syntax (or node complains that it can't find the named export of the thing you're importing from `nanoid-dictionary` please rather install the beta version, like this

`npm i nanoid-dictionary@beta`


## Usage

Require a `customAlphabet` from `nanoid` and pass a string from the dictionary:

```javascript
import { customAlphabet } from 'nanoid';
import { lowercase } from 'nanoid-dictionary';

const lowercaseRandomString = customAlphabet(lowercase, 10);
```


## Character sets

### `numbers`

Numbers from 0 to 9

```javascript
import { numbers } from 'nanoid-dictionary';
```

### `hexadecimalLowercase`

Lowercase English hexadecimal lowercase characters: `0123456789abcdef`

```javascript
import { hexadecimalLowercase } from 'nanoid-dictionary';
```

### `hexadecimalUppercase`

Lowercase English hexadecimal uppercase characters: `0123456789ABCDEF`

```javascript
import { hexadecimalUppercase } from 'nanoid-dictionary';
```

### `lowercase`

Lowercase English letters: `abcdefghijklmnopqrstuvwxyz`

```javascript
import { lowercase } from 'nanoid-dictionary';
```

### `uppercase`

Uppercase English letters: `ABCDEFGHIJKLMNOPQRSTUVWXYZ`

```javascript
import { uppercase } from 'nanoid-dictionary';
```

### `alphanumeric`

Combination of all the lowercase, uppercase characters and numbers from 0 to 9

Does not include any symbols or special characters

```javascript
import { alphanumeric } from 'nanoid-dictionary';
```

### `nolookalikes`

Numbers and english alphabet without lookalikes: `1`, `l`, `I`, `0`, `O`, `o`, `u`, `v`, `5`, `S`, `s`, `2`, `Z`.

Complete set: `346789ABCDEFGHJKLMNPQRTUVWXYabcdefghijkmnpqrtwxyz`

```javascript
import { nolookalikes } from 'nanoid-dictionary';
```

### `nolookalikesSafe`

Same as `nolookalikes` but with removed vowels and following letters: `3`, `4`, `x`, `X`, `V`.

This list should protect you from accidentally getting obscene words in generated strings.

Complete set: `6789BCDFGHJKLMNPQRTWbcdfghjkmnpqrtwz`

```javascript
import { nolookalikesSafe } from 'nanoid-dictionary';
```

### `cookieSafe`

All the allowed characters for a cookie value defined in [RFC6225](https://www.rfc-editor.org/rfc/rfc6265.txt).

```javascript
import { cookieSafe } from 'nanoid-dictionary';
```

### `cookieUnsafe`

All the characters that [actually work in modern browsers](https://stackoverflow.com/a/1969339).
Might not be suitable for servers, use with caution.

```javascript
import { cookieUnsafe } from 'nanoid-dictionary';
```

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