Skip to content

compromise

A small JavaScript library that parses English text and lets you search, read, and transform it.

Stars
12.2k
Forks
672
Licence
MIT
Language
JavaScript
Last update
7 days ago
Type
Library

What it is

compromise is a JavaScript library for working with English text in a programmatic way. You give it a sentence or document, and it can find parts of speech like verbs and nouns, match patterns, pull out data such as numbers and places, and rewrite text (for example, changing verbs to past tense or expanding contractions). The README describes it as making limited, sensible decisions rather than being a deep AI model, and says it is meant to be small and fast.

  • Convert a sentence's verbs to past tense or negative form with a few lines of code
  • Find phrases matching a pattern such as 'the #Adjective of times' in a long text
  • Expand contractions like "we're" into "we are" before further processing
  • Add or subtract numbers written as words, such as 'two bottles of beer' minus one
  • Extract places or syllables from text with the optional compromise-speech plugin

Great for

  • JavaScript developers who need simple English text analysis inside a web or Node app
  • Projects that want pattern matching on text without running a large language model
  • Developers who want to run text processing in the browser on the client side
  • People building quick text transforms such as pluralizing nouns or converting numbers

Not ideal for

  • Users who need highly accurate parsing across many languages: the README points to separate projects for French, German, Italian, and Spanish, so the core library is English-focused
  • Projects needing state-of-the-art understanding or reasoning, since the README itself says it is 'not as smart as you'd think'
  • Non-programmers looking for a ready-made app, because it is used through code
Step-by-step guide: how to use compromiseInstall, first run, examples, tips and FAQs

How to get it

  1. 1

    Install with a package manager

    You'll need: Node.js (version not stated in the README)

    Install from npm

    npm install compromise
  2. 2

    Run it

    • Run npm install compromise in your project folder
    • Create a file and add: import nlp from 'compromise'
    • Call nlp('she sells seashells by the seashore.') and then doc.verbs().toPastTense()
    • Print doc.text() to see the transformed sentence
  3. 3

    Get the most out of it

    • Use doc.match() with patterns like '#Verb' or '#Adjective' to pull out specific parts of text
    • Add the compromise-speech plugin with nlp.extend(plg) to get syllables and place data
    • Use doc.contractions().expand() to normalize informal text before analysis
    • Check the linked observablehq docs for match, JSON, and noun examples

Downloads

Strengths

  • Small footprint and quick enough to run on each keypress, according to the README's performance notes
  • Works in both Node.js and the browser, with an npm install or a script tag
  • Pattern-matching syntax is simple, and it ships with documented examples

Trade-offs

  • The README says it makes limited decisions and is not as smart as a modern AI model, so results can be wrong on unusual text
  • Its English lexicon is about 14,000 words, which limits coverage of rarer vocabulary
  • The bundle is around 250kb minified per the README, which may be large for very small pages

How it compares

ProjectStarsTypeLevelUpdatedBest for
compromise (this)12.2kLibrarybeginner7 days agoJavaScript developers who need simple English text analysis inside a web or Node app
natural10.9kLibraryintermediate11 days agoJavaScript or TypeScript developers who need basic text processing on a Node.js server
spaCy34kLibraryintermediate10 days agoPython developers building text-processing features into an application
nano-vllm16.3kLibraryintermediate6 months agoDevelopers who want to understand how LLM inference engines work internally
botpress15kDev toolintermediate6 days agoDevelopers who want to write integrations and bots as TypeScript code using the Botpress CLI and SDK
AI-For-Beginners70.5kLearning resourcebeginner13 days agoBeginners who want a structured, self-paced introduction to AI

Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.