JavaScript NLP libraries

Updated Nov 2026

JavaScript NLP libraries analyze text in Node.js and the browser, from splitting it into tokens to tagging words and detecting its language. Local libraries process text with rules, statistics, or pretrained models instead of a hosted API. These libraries let apps and AI agents count model tokens, classify text, and tag parts of speech.

Popularity

OpenAI Node has the most monthly downloads in this comparison, at 223.6M, a count that covers every use of the OpenAI API rather than text analysis alone.

LibraryMonthly downloadsStarsLast releaseLicense
openai
223.6M
11.3KNov 2026Apache-2.0
AI SDK
172.3M
28.1KNov 2026Apache-2.0
js-tiktoken
49.4M
1.1KAug 2025MIT
@huggingface/transformers
19.1M
16.4KOct 2026Apache-2.0
gpt-tokenizer
10.6M
862Nov 2026MIT
Natural
7.6M
10.9KOct 2026MIT
franc-min
7.0M
4.4KJan 2024MIT
compromise
5.7M
12.2KNov 2026MIT
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Provides the official TypeScript library for the OpenAI API.

Downloads / mo
223.6M
Stars
11.3K
Last release
7.60.0
License
Apache-2.0

Quickstart

From moderations.ts
$ npm install openai
import OpenAI from 'openai'

const client = new OpenAI()
const result = await client.moderations.create({ input: 'Hello, world!' })

openai examples

From open-source projects on GitHub

Builds AI apps with a single interface for any model provider.

Downloads / mo
172.3M
Stars
28.1K
Last release
7.0.177
License
Apache-2.0

Quickstart

From reranking
$ npm install ai @ai-sdk/cohere
import { rerank } from 'ai'
import { cohere } from '@ai-sdk/cohere'

const result = await rerank({ model: cohere.reranking('rerank-v4.0-pro'), query: 'rain', documents: ['a rainy day', 'a sunny day'] })

AI SDK examples

From open-source projects on GitHub

js-tiktoken

Ports the tiktoken tokenizer to JavaScript.

Downloads / mo
49.4M
Stars
1.1K
Last release
1.0.21
License
MIT

Quickstart

From README.md
$ npm install js-tiktoken
import { getEncoding } from 'js-tiktoken'

const encoder = getEncoding('gpt2')
const tokenIds = encoder.encode('hello world')

@huggingface/transformers

Runs Transformers models directly in the browser, with no server.

Downloads / mo
19.1M
Stars
16.4K
Last release
4.3.2
License
Apache-2.0

Quickstart

From README.md
$ npm install @huggingface/transformers
import { pipeline } from '@huggingface/transformers'

const classifier = await pipeline('sentiment-analysis')
const result = await classifier('I love transformers!')

@huggingface/transformers examples

From open-source projects on GitHub

Encodes text as BPE tokens for OpenAI models in pure JavaScript.

Downloads / mo
10.6M
Stars
862
Last release
4.1.2
License
MIT

Quickstart

From README.md
$ npm install gpt-tokenizer
import { encode } from 'gpt-tokenizer'

const tokenIds = encode('Hello, world!')

gpt-tokenizer examples

From open-source projects on GitHub

Provides tokenizers, classifiers, word scoring, and other NLP algorithms for Node.js.

Downloads / mo
7.6M
Stars
10.9K
Last release
8.2.6
License
MIT

Strengths

  • Configures token boundaries. Choose word, Treebank, or regular-expression tokenizers for the input.
  • Trains reusable text classifiers. Train a BayesClassifier on labeled text, then classify new inputs.

Limitations

  • Sentiment follows word vocabularies. Scores sum word polarities and account for negation.
$ npm install natural
import natural from 'natural'

const tokenizer = new natural.WordTokenizer()
const words = tokenizer.tokenize('your dog has fleas.')

Natural examples

From open-source projects on GitHub

Detects the language of a text.

Downloads / mo
7.0M
Stars
4.4K
Last release
6.2.0
License
MIT

Quickstart

From readme.md
$ npm install franc-min
import { franc } from 'franc-min'

const language = franc('All human beings are born free and equal in dignity and rights.')

franc-min examples

From open-source projects on GitHub

compromise

Provides rule-based English text tagging, selection, and transformation.

Downloads / mo
5.7M
Stars
12.2K
Last release
14.20.0
License
MIT

Strengths

  • Selects and transforms text. Find matching text spans and change their grammar through chained methods.
  • Supports custom words and tags. Add domain vocabulary at parse time or through global lexicon methods.

Limitations

  • Transforms mutate the shared document. Call clone before transforming a copy that must preserve the original.
  • Matches stay within sentence boundaries. Use the paragraphs plugin when a match must cross sentences.

Quickstart

From concepts.md
$ npm install compromise
import nlp from 'compromise'

const doc = nlp('she sells seashells by the seashore.')
const past = doc.verbs().toPastTense().text()

FAQ

compromise suits rule-based English tagging and text transformation. Natural suits tokenizers, stemmers, and classifiers in Node.js. Transformers.js suits pretrained models for tasks such as translation and token classification.

The OpenAI moderation API classifies text into predefined moderation categories. OpenAI Node calls it as a hosted service rather than running a local model.

js-tiktoken and gpt-tokenizer encode text into the BPE token IDs that OpenAI models read. Both run locally in pure JavaScript.

Transformers.js runs pretrained NLP pipelines and tokenizers locally in the browser or Node.js. The available tasks and languages depend on the model.

franc-min identifies the language of a text from statistical evidence across the whole text. It returns a language code rather than tags for each word.

For coding agents

Found your NLP library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official