Check grammar of Word, PDF, Web documents in JavaScript

Check grammar of documents using JavaScript.

Seamless integration with major language models such as OpenAI, Claude and Gemini provides extensive AI-based document processing capabilities for Node.js applications.

View code snippet

AI Grammar Checker for Documents in JavaScript

Detect and highlight grammar errors in documents using OpenAI, Google, and Claude AI models with Aspose.Words for Node.js via .NET. The CheckGrammar method analyzes DOC, DOCX, RTF, PDF, HTML, Markdown, ODT, TXT, and EPUB files and marks grammatical problems — helping you deliver polished, professional content without manual proofreading.

Why Developers Choose Aspose.Words for Grammar Checking

  • One API call to grammar-check an entire document
  • Support for OpenAI (GPT-4o), Google (Gemini), and Claude model families
  • Highlighted errors in the output document for easy review
  • Support for DOC, DOCX, RTF, PDF, ODT, HTML, Markdown, TXT, EPUB, and more

Authentication requires an API key from your chosen AI provider. For a full list of supported models, see the API Reference.

Start checking grammar in JavaScript today — try the live demo above.

Example code in JavaScript for grammar checking
Select the target format from the list
Run code
npm install @aspose/words
Copy
const aw = require('@aspose/words');

const doc = new aw.Document("Document.docx");
const apiKey = process.env.API_KEY;

// Use OpenAI generative language models.
const model = aw.AI.AiModel.createGpt4OMini();
model.setApiKey(apiKey);

const grammarOptions = new aw.AI.CheckGrammarOptions();
grammarOptions.improveStylistics = true;

const proofedDoc = model.checkGrammar(doc, grammarOptions);
proofedDoc.save("Output.docx");
const aw = require('@aspose/words');

const doc = new aw.Document("Document.docx");
// Pass an empty string if the self-hosted model does not require an API key.
const model = new CustomAiModel("my-model-24b", "https://your-server.com/v1");
model.setApiKey("");

const grammarOptions = new aw.AI.CheckGrammarOptions();
grammarOptions.improveStylistics = true;

const proofedDoc = model.checkGrammar(doc, grammarOptions);
proofedDoc.save("Output.docx");

class CustomAiModel extends aw.AI.OpenAiModel {
    constructor(name, url) {
        super(name);
        this._url = url;
    }
    get url() {
        return this._url;
    }
}
Run code

How to check grammar in a document using JavaScript

  1. Install Aspose.Words for Node.js via .NET.
  2. Add a library reference (import the library) to your JavaScript project.
  3. Open the source file in JavaScript.
  4. Invoke CheckGrammar method, passing in your document.
  5. Once completed, the grammatical issues in the document will be highlighted, and you can save the result as a new file in the format you need.

Node.js via .NET library to check grammar

We host our Node.js via .Net packages in NPM repositories. Please follow the step-by-step instructions on how to install "Aspose.Words for Node.js via .NET" to your developer environment.

System Requirements

This package is compatible with Node.js 14.17.0 or higher.

5%

Subscribe to Aspose Product Updates

Get monthly newsletters and offers directly delivered to your mailbox.

© Aspose Pty Ltd 2001-2026. All Rights Reserved.