Compare Word Documents

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
Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.