Eskillsfy

Home / Blog / Articles

Articles · 23 Nov 2026

AI Grammar Checker: how it works and how to build one

Fix spelling, grammar and punctuation, with a list of changes. This guide explains what happens behind the button and shows the code, so you can build your own.

What it does

Corrects spelling, grammar and punctuation in US, UK or Indian English without changing your tone. Under the corrected text you get a short list of what changed, so you learn from it.

When to use it

  • Emails and cover letters
  • Blog posts before publishing
  • Non-native writers checking their English
  • Product copy

How to use it

  1. Log in.
  2. Paste your text and choose the English variety.
  3. Copy the corrected text and read the list of changes.

Try it free with an Eskillsfy account: https://eskillsfy.com/tools/ai-grammar-checker

How it works

Classic grammar checkers use hand-written rules. An AI grammar checker instead asks a language model to return the corrected text, which handles awkward phrasing that rules miss.

To make the result useful for learning, the prompt also asks for a short list of changes after a separator line. The page shows both, so you can see what changed and why.

Build it yourself

Here is the core of the tool. It has no dependencies unless noted, so you can paste it into any Node.js project.

server/routes/ai-grammar-checker.js (js)

// Express route. The prompt stays on the server, so the endpoint can only do this one job.
import { Router } from "express";
const router = Router();

const SYSTEM = (option) => `Correct spelling, grammar and punctuation in ${option}. Do not change meaning or tone. After the text, add '---' and list the main changes.`;

router.post("/ai-grammar-checker", requireUser, async (req, res) => {
  const input = String(req.body.input ?? "").trim();
  if (!input || input.length > 8000) return res.status(400).json({ error: "Send 1 to 8,000 characters." });
  const option = ALLOWED.includes(req.body.option) ? req.body.option : ALLOWED[0];

  // Any chat model works here: Gemini on Vertex AI, the Claude API, etc.
  const r = await fetch("https://api.anthropic.com/v1/messages", {
    method: "POST",
    headers: { "x-api-key": process.env.ANTHROPIC_API_KEY, "anthropic-version": "2023-06-01", "content-type": "application/json" },
    body: JSON.stringify({ model: process.env.AI_MODEL, max_tokens: 2048, system: SYSTEM(option), messages: [{ role: "user", content: input }] }),
  });
  if (!r.ok) return res.status(502).json({ error: "The AI service did not answer." });
  const data = await r.json();
  res.json({ output: data.content.map((b) => b.text ?? "").join("").trim() });
});

export default router;

Make it production-ready

  • Put the API key in a secret manager and read it from an environment variable, never in frontend code.
  • Require a login and add a per-user daily limit so one person can’t run up your bill.
  • Validate the option against a fixed list so users can’t inject their own instructions.
  • Show a loading state and a clear error when the provider is slow or down.

Questions

Will it rewrite my style?

No. It only fixes errors. Use the AI Paraphraser if you want a different style.

Try the AI Grammar Checker

Free with an Eskillsfy account.

Open it