GuideAugust 21, 20263 min read

Word document editor for legal applications

Build custom redlining agents and legal review workflows with a DOCX editing API and a customizable review UI.

If you build legal software, your users often need to return a valid Word document. DOCX Editor provides the document API and review UI for custom redlining agents, contract portals, and document management systems.

It is not a fixed legal copilot. Your application controls the agent, legal rules, user interface, storage, and approval workflow.

Try the document editor

Open a contract or edit the sample document:

This preview shows the open-source editor. The Pro module adds tracked changes, comments, and the review rail.

Build a custom redlining agent

A redlining agent can read a contract, identify clauses, and propose edits. The final document must show each proposal as a Word tracked change.

A typical integration uses this flow:

  1. Your application loads the original .docx file.
  2. The automation API reads the current document structure and text.
  3. Your model or rules engine proposes clause changes.
  4. The integration writes each proposal as a tracked change.
  5. Your review interface lets users accept, reject, or comment.

@docx-editor.dev/editor-api gives agents an Office.js-compatible object model. An agent can read paragraphs and tables, search text, change content, and apply formatting through programmatic operations.

Use the browser entry to edit a document that a user has open. Use the headless entry to process DOCX bytes in an API route, job, or script. The package does not choose a model or define review rules. Your application controls the agent, prompts, permissions, and audit records.

You can connect the API to Vercel AI SDK or another tool-calling framework. Define tools for the exact operations that your legal workflow allows. For example, one agent can only search and comment. Another can propose tracked replacements after it checks a clause library.

Browser operations that create comments or revisions need the Pro review module in the attached editor.

For example, an agent tool can find a clause and add a review comment:

await runtime.run(async (context) => {
  const matches = context.document.body.search("limitation of liability");
  matches.load("items");
  await context.sync();
 
  matches.items[0]?.insertComment("Check this clause against the playbook.");
  await context.sync();
});

For more information, see the programmatic editing API and the DOCX editing API for AI agents.

The contract redlining API guide shows how to define an AI SDK tool and execute its proposal against the open editor.

Add a contract review portal

A contract lifecycle management system can keep review inside its own product. Load the document bytes from your storage and pass them to the editor:

import { DocxEditor } from "@docx-editor.dev/react";
import { DocxEditorReview, reviewModule } from "@docx-editor.dev/pro/react";
import "@docx-editor.dev/core/styles/editor.css";
 
const MODULES = [reviewModule()];
 
export function ContractReview({ bytes }: { bytes: Uint8Array }) {
  return (
    <DocxEditor.Root
      document={bytes}
      modules={MODULES}
      author="Legal review"
      mode="suggesting"
    >
      <DocxEditor.Toolbar />
      <DocxEditor.Viewport>
        <DocxEditor.Content />
        <DocxEditorReview />
      </DocxEditor.Viewport>
    </DocxEditor.Root>
  );
}

The Pro module records insertions, deletions, and formatting edits as tracked changes. Comments attach questions and replies to text ranges. Reviewers can save the result as a .docx file and continue in Microsoft Word.

The UI is composable. You can replace the toolbar, arrange the review rail, add a clause panel, or place your agent chat beside the document. Users can accept, reject, edit, undo, and comment on agent proposals.

For setup instructions, see tracked changes and comments. For automated proposals, see the contract redlining API guide.

Connect a document management system

Your application can fetch DOCX bytes from its document store. Call save() through the editor ref, then send the returned ArrayBuffer to your API.

The editor processes files in the browser. It sends no document to a third-party editing service. Your integration still owns authentication, storage, version history, retention, and access controls.

The loading and saving guide covers the file boundary between the editor and your storage layer.

Decide if it fits

DOCX Editor works with Office Open XML (OOXML) instead of converting contracts to HTML. This approach suits products that must preserve Word document structure during editing.

The React and Vue adapters use the Apache 2.0 license. Tracked changes, comments, custom nodes, and the automation API use commercial licenses.

Use the React Word editor guide or the Vue Word editor guide to start. For a framework-neutral overview, see how to edit Word documents in your app.

Use the Word fidelity guide to check clauses, numbering, tables, headers, footers, and other contract structures.

Content controls support structured fields inside a document. Custom nodes support application-specific objects with their own rendering and review behavior. The Pro overview explains their production license.