Introduction

Whether you work with contracts, internal policies, technical specifications, or marketing copies, the pattern is the same: you quickly accumulate several .docx versions and at some point need to see what exactly changed between them. Word’s built‑in Compare dialog is fine for an occasional manual check, but it does not help much when comparison becomes part of a regular process or has to be automated on the server side.

GroupDocs.Comparison for .NET lets you run that comparison from code and produce the result in the format your reviewers prefer. The library supports two output modes for Word documents:

  1. Revision mode — differences are written as Word revision (track‑changes) markup. Reviewers open the file, see the familiar Review → Accept / Reject controls, and work through changes one by one.
  2. Highlight mode — inserted, deleted, and modified text is rendered with colour highlights directly in the document body, so differences are visible at a glance while you read the final text.

In this article we will walk through both approaches with working C# examples, explore the WordCompareOptions class and its properties, and discuss when each mode makes more sense.

Prerequisites

Before you start:

  • .NET 6.0 or later.
  • GroupDocs.Comparison for .NET — install via NuGet:
dotnet add package GroupDocs.Comparison
  • A license file (GroupDocs.Comparison.lic). Without it the library runs in evaluation mode with watermarks and size limits. You can request a temporary license for testing.
  • Two Word files to compare — we will call them source.docx and target.docx. Example content:
source.docx target.docx

Method 1: Revision‑Track Comparison

When to use: reviewers need to accept or reject each change individually in Microsoft Word using the built‑in Review → Accept / Reject tools — for example, during contract negotiation or policy approval cycles.

using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;

using (var comparer = new Comparer("source.docx"))
{
    comparer.Add("target.docx");

    var options = new WordCompareOptions
    {
        DetectStyleChanges = true,
        DisplayMode = WordCompareOptions.ComparisonDisplayMode.Revisions
    };

    comparer.Compare("result_revision.docx", options);
}

Resulting document in revision (track changes) mode:

Comparison result in revision (track changes) mode

What happens under the hood:

  • ComparisonDisplayMode.Revisions tells the engine to emit native Word track‑changes markup.
  • DetectStyleChanges = true makes the comparison pick up formatting differences (bold, font size, colour) alongside textual edits.
  • The output file opens in Microsoft Word with the Review pane ready — every insertion, deletion, and style tweak is listed and can be accepted or rejected.

Because revision mode does not need to re‑render the document content — it simply attaches revision metadata — it tends to be the faster of the two modes.


Method 2: Highlight‑Mode Comparison

When to use: stakeholders want a clean document that clearly shows what changed but are not interested in working through every single revision. A typical scenario is a manager who opens the latest version in Word and quickly scans highlighted insertions and deletions to understand the impact of the update.

using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;

using (var comparer = new Comparer("source.docx"))
{
    comparer.Add("target.docx");

    var options = new WordCompareOptions
    {
        DetectStyleChanges = true,
        DisplayMode = WordCompareOptions.ComparisonDisplayMode.Highlight
    };

    comparer.Compare("result_highlighted.docx", options);
}

Resulting document in highlight mode:

Comparison result in highlight mode

What happens under the hood:

  • ComparisonDisplayMode.Highlight renders differences as inline colour highlights — red for deletions, green for insertions, blue for style changes (default colours that can be adjusted through WordCompareOptions / CompareOptions and their related StyleSettings).
  • The document is ready for reading or printing without any extra steps.
  • No track‑changes metadata is added to the file.

Highlight mode does more work internally because it has to modify the actual document content and apply formatting. For large files you may notice a significant performance difference compared to revision mode.


Exploring WordCompareOptions

Both examples above use WordCompareOptions — a class that inherits common settings from CompareOptions and adds properties specific to Word documents. Through this type you control display mode (DisplayMode), whether to track style changes (DetectStyleChanges), which author name appears on revisions (RevisionAuthorName), how line breaks, bookmarks etc.

On top of that, the base CompareOptions exposes styles for inserted, deleted, and changed items (InsertedItemStyle, DeletedItemStyle, ChangedItemStyle), so you can fine‑tune colours and formatting of the highlights when needed.

Here is a small example of configuring options for a text‑only check in revision mode:

var options = new WordCompareOptions
{
    DisplayMode = WordCompareOptions.ComparisonDisplayMode.Revisions,
    DetectStyleChanges = false,
    RevisionAuthorName = "QA Bot",
    CompareBookmarks = true
};

Getting Changes Programmatically

Regardless of which output mode you choose (revisions or highlight), you can always obtain a structured list of detected differences via the common Comparer.GetChanges API. This method works for Word and all other supported formats.

using (var comparer = new Comparer("source.docx"))
{
    comparer.Add("target.docx");

    comparer.Compare("result_revision.docx");

    var changes = comparer.GetChanges(); // returns ChangeInfo[]
}

This is useful when you need to post‑process changes in your own workflow — for example, to build a custom HTML report, feed differences into a review system, or aggregate statistics about edits. See the official API reference for more details: Comparer.GetChanges.


Working with Password‑Protected Documents

If documents are protected with a password, they can still be compared: the password is passed via LoadOptions when creating the Comparer. This approach works the same way for Word, PDF, and other supported formats.

using GroupDocs.Comparison;
using GroupDocs.Comparison.Options;

using (var comparer = new Comparer("source_protected.docx",
    new LoadOptions { Password = "secret" }))
{
    comparer.Add("target_protected.docx");

    var options = new WordCompareOptions
    {
        DisplayMode = WordCompareOptions.ComparisonDisplayMode.Revisions
    };

    comparer.Compare("result_protected.docx", options);
}

Get a Free Trial

You can download GroupDocs.Comparison for .NET from the official releases page. For unrestricted testing, request a temporary license — no credit card required.


Frequently Asked Questions

Q: Do I need Microsoft Word or Office installed on the server? A: No. GroupDocs.Comparison is a standalone .NET library; it reads and writes DOCX files on its own.

Q: Can I compare documents in other formats besides Word? A: Yes — the library supports PDFs, Excel spreadsheets, presentations, plain‑text files, and many more. The full list is in the documentation.

Q: What happens if I don’t set a license? A: The library works in evaluation mode. Output documents will contain a watermark and only the first few pages are processed. A temporary license removes these restrictions for testing.

Q: Can I customise the highlight colours? A: The default colours work for most use cases. For advanced styling control, check the StyleSettings property on CompareOptions.


Conclusion

GroupDocs.Comparison for .NET gives you two clean ways to diff Word documents from code. Revision mode plugs straight into the review workflow your team already uses; highlight mode delivers an instant visual summary for people who just need to see the changes. The WordCompareOptions class lets you fine‑tune the output — from style detection and author attribution to bookmark and document‑property comparison.

Pick the mode that fits your scenario, or generate both and let each audience choose their preferred view.

Additional Resources