# cspell-lib

> A library of useful functions used across various cspell tools.

Latest version **10.3.3** (published 2026-09-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install cspell-lib
pnpm add cspell-lib
yarn add cspell-lib
bun add cspell-lib
```

## Health

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

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

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 10.3.3 |
| Published | 2026-09-16 |
| First published | 2017-02-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=22.18.0 |
| Dependencies | 23 |
| Unpacked size | 548.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 1685 |
| Author | Jason Dent |
| Maintainers | jason-dent |
| Keywords | spell, checker, code, camel, case, spelling, spell checker, spelling checker, lint |

## Links

- npm: https://www.npmjs.com/package/cspell-lib
- Repository: https://github.com/streetsidesoftware/cspell
- Homepage: https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-lib#readme
- Issues: https://github.com/streetsidesoftware/cspell/labels/cspell-lib
- npm.io page: https://npm.io/package/cspell-lib

## Dependencies (23)

- [cspell-io](https://npm.io/package/cspell-io.md) 10.3.3
- [env-paths](https://npm.io/package/env-paths.md) ^4.0.0
- [vscode-uri](https://npm.io/package/vscode-uri.md) ^3.2.0
- [@cspell/rpc](https://npm.io/package/@cspell/rpc.md) 10.3.3
- [@cspell/url](https://npm.io/package/@cspell/url.md) 10.3.3
- [cspell-glob](https://npm.io/package/cspell-glob.md) 10.3.3
- [gensequence](https://npm.io/package/gensequence.md) ^8.0.8
- [xdg-basedir](https://npm.io/package/xdg-basedir.md) ^5.1.0
- [import-fresh](https://npm.io/package/import-fresh.md) ^4.0.0
- [resolve-from](https://npm.io/package/resolve-from.md) ^5.0.0
- [cspell-grammar](https://npm.io/package/cspell-grammar.md) 10.3.3
- [cspell-trie-lib](https://npm.io/package/cspell-trie-lib.md) 10.3.3
- [@cspell/filetypes](https://npm.io/package/@cspell/filetypes.md) 10.3.3
- [cspell-config-lib](https://npm.io/package/cspell-config-lib.md) 10.3.3
- [cspell-dictionary](https://npm.io/package/cspell-dictionary.md) 10.3.3
- [@cspell/cspell-pipe](https://npm.io/package/@cspell/cspell-pipe.md) 10.3.3
- [@cspell/cspell-types](https://npm.io/package/@cspell/cspell-types.md) 10.3.3
- [@cspell/dynamic-import](https://npm.io/package/@cspell/dynamic-import.md) 10.3.3
- [@cspell/cspell-resolver](https://npm.io/package/@cspell/cspell-resolver.md) 10.3.3
- [@cspell/strong-weak-map](https://npm.io/package/@cspell/strong-weak-map.md) 10.3.3
- [@cspell/cspell-bundled-dicts](https://npm.io/package/@cspell/cspell-bundled-dicts.md) 10.3.3
- [@cspell/cspell-performance-monitor](https://npm.io/package/@cspell/cspell-performance-monitor.md) 10.3.3
- [vscode-languageserver-textdocument](https://npm.io/package/vscode-languageserver-textdocument.md) ^1.0.14

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 10.3.3 (latest) — 2026-09-16
- 10.3.4-alpha.0 (next) — 2026-09-17
- 5.21.2 (cspell5) — 2022-05-21
- 5.21.2-alpha.0 (cspell5-next) — 2022-05-20
- 4.3.12 (cspell4) — 2021-01-23
- 10.3.2 — 2026-09-15
- 10.3.2-alpha.0 — 2026-09-13
- 10.3.1 — 2026-09-13
- 10.3.1-alpha.1 — 2026-09-12
- 10.3.1-alpha.0 — 2026-09-12
- 10.3.0 — 2026-09-08
- 10.3.0-alpha.0 — 2026-09-04
- 10.2.2 — 2026-09-04
- 10.2.1 — 2026-09-03
- 10.2.0 — 2026-08-31
- … 405 more at https://npm.io/package/cspell-lib/versions

## README

# CSpell Library

`cspell-lib` is the workhorse behind cspell. It does all the heavy lifting necessary to spell check files.

## Support Future Development

<!--- @@inject: ../../static/sponsor.md --->

If our spell checkers save you time, please consider supporting their development.

<p align="left">
  <a href="https://github.com/sponsors/streetsidesoftware" title="GitHub Sponsor"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cspell.org/img/sponsor/github-sponsor-dark.png" /><img alt="GitHub Sponsor" src="https://cspell.org/img/sponsor/github-sponsor.png" width="180" /></picture></a> &nbsp; <a href="https://www.paypal.com/donate/?hosted_button_id=26LNBP2Q6MKCY" title="PayPal"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cspell.org/img/sponsor/paypal-dark.png" /><img alt="PayPal" src="https://cspell.org/img/sponsor/paypal.png" width="180" /></picture></a> &nbsp; <a href="https://opencollective.com/cspell" title="Open Collective"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cspell.org/img/sponsor/open-collective-dark.png" /><img alt="Open Collective" src="https://cspell.org/img/sponsor/open-collective.png" width="180" /></picture></a> &nbsp; <a href="https://streetsidesoftware.com/sponsor/" title="Street Side Software"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cspell.org/img/sponsor/cspell-dark.png" /><img alt="CSpell" src="https://cspell.org/img/sponsor/cspell.png" width="180" /></picture></a>
</p>

<!--- @@inject-end: ../../static/sponsor.md --->

## Installation

```
npm i -S cspell-lib
```

## Usage

### Example - Check some text

Here is an example of using `spellCheckDocument` to spell check some text with a spelling issue.

```ts
import assert from 'node:assert';

import { spellCheckDocument } from 'cspell-lib';

// cspell:ignore wordz coztom clockz cuztom
const customWords = ['wordz', 'cuztom', 'clockz'];

async function checkSpelling(phrase: string) {
  const result = await spellCheckDocument(
    { uri: 'text.txt', text: phrase, languageId: 'plaintext', locale: 'en' },
    { generateSuggestions: true, noConfigSearch: true },
    { words: customWords, suggestionsTimeout: 2000 }
  );
  return result.issues;
}

export async function run() {
  console.log(`Start: ${new Date().toISOString()}`);
  const r = await checkSpelling('These are my coztom wordz.');
  console.log(`End: ${new Date().toISOString()}`);
  // console.log(r);
  assert(r.length === 1, 'Make sure we got 1 spelling issue back.');
  assert(r[0].text === 'coztom');
  assert(r[0].suggestions?.includes('cuztom'));
  // console.log('%o', r);
}
```

### Example - Check a file

```ts
import { resolve } from 'node:path';
import { pathToFileURL } from 'node:url';
import { spellCheckDocument } from 'cspell-lib';

export async function checkFile(filename: string) {
  const uri = pathToFileURL(resolve(filename)).toString();
  const result = await spellCheckDocument(
    { uri },
    { generateSuggestions: true, noConfigSearch: true },
    { words: customWords, suggestionsTimeout: 2000 }
  );
  return result.issues;
}
```

## CSpell for Enterprise

<!--- @@inject: ../../static/tidelift.md --->

Available as part of the Tidelift Subscription.

The maintainers of cspell and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-cspell?utm_source=npm-cspell&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

<!--- @@inject-end: ../../static/tidelift.md --->

<!--- @@inject: ../../static/footer.md --->

<br/>

---

<p align="center">Brought to you by<a href="https://streetsidesoftware.com" title="Street Side Software"><img width="16" alt="Street Side Software Logo" src="https://i.imgur.com/CyduuVY.png" /> Street Side Software</a></p>

<!--- @@inject-end: ../../static/footer.md --->

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