Compare Word Documents

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Comparison MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-comparison -- dnx GroupDocs.Comparison.Mcp --yes
Folders, licensing and more →

GroupDocs.Comparison for Python via .NET compares Word documents and highlights differences in text, formatting, styles, and structure. Typical use cases include legal contracts, business reports, and any collaborative editing workflow where accurate change tracking matters.

The API:

  • Compares DOC and DOCX files (and Word-compatible formats such as RTF, ODT, DOT, DOTX).
  • Highlights insertions, deletions, and formatting changes.
  • Exports the result as a Word document or any other supported format.

Steps to compare Word documents

  1. Create a Comparer instance and load the source Word document.
  2. Add one or more target Word documents via add().
  3. Call compare() to generate the result file.

Example: Compare Word documents

from groupdocs.comparison import Comparer

def compare_word_documents():
    with Comparer("./source.docx") as comparer:
        comparer.add("./target.docx")
        comparer.compare("./result.docx")

if __name__ == "__main__":
    compare_word_documents()

source.docx is the source file used in this example. Click here to download it.

target.docx is the target file used in this example. Click here to download it.

Binary file (DOCX, 25 KB)

Download full output

Word-specific options

The base flow above works for any Word format, but several options on CompareOptions are specifically useful when comparing Word documents:

OptionPurposeTopic
word_track_changesInclude or ignore previously-tracked revisionsWord track changes
compare_bookmarksDetect changes inside bookmarked rangesCompare bookmarks in Word documents
revision_author_nameAttribute changes in the result to a specific authorSetting author of changes
show_revisionsShow or hide inline revision markers in the resultShow revisions
compare_variable_property / compare_document_propertyCompare document metadataCompare variables and document properties