Skip to main content
@usejunior/docx-core is the production engine behind Safe Docx. It provides the primitives, comparison engine, and track-changes infrastructure used by the MCP server — packaged for direct import in any TypeScript or JavaScript application. Primary capabilities:
  • Tracked-change comparison output for review workflows
  • Revision extraction and OOXML-safe document primitives
  • Formatting-preserving text and paragraph operations
  • Comment and footnote primitive support

When to use it directly

Use @usejunior/docx-core when you need to:
  • Run document comparison programmatically inside your own server or serverless function
  • Build tooling on top of the OOXML primitives (accept/reject changes, add comments, etc.)
  • Integrate Safe Docx into a pipeline without a running MCP server
Use @usejunior/safe-docx via npx when you want the MCP server for agent-driven editing workflows where a coding assistant (Claude, Cursor, etc.) invokes tools.

Installation

npm install @usejunior/docx-core

Quickstart

import { readFile, writeFile } from 'node:fs/promises';
import { compareDocuments } from '@usejunior/docx-core';

const original = await readFile('./original.docx');
const revised = await readFile('./revised.docx');

const result = await compareDocuments(original, revised, {
  author: 'Comparison',
  // engine defaults to 'auto' (atomizer)
});

await writeFile('./output.redline.docx', result.document);
console.log(result.engine, result.stats);
// => 'atomizer' { insertions: 3, deletions: 1, modifications: 0 }
See compareDocuments for the full API reference.

Runtime requirements

RequirementDetail
Node.js>= 18.0.0
Cloudflare WorkersSupported
Vercel FunctionsSupported
AWS Lambda / Lambda@EdgeSupported
Any V8 isolateSupported

Dependency footprint

Runtime dependencies are intentionally minimal: No native binaries. No .NET prerequisite. The package works in any standard JavaScript runtime.

Build docs developers (and LLMs) love