diff_fragments
Compare two .docx files to reveal paragraph and table-level text differences. See exactly what changed between document versions.
Instructions
Compare two .docx files and show paragraph and table-level text differences.
Extracts the pseudo-Markdown text from each paragraph and table cell in both documents, then produces a word-level diff for each fragment position. This is useful for understanding what changed between two versions of a document.
Use this tool:
To compare an original document with its redlined version (see what changes were applied)
To verify that
apply_changesproduced the expected modificationsTo understand differences between two versions of a document
Important Limitations
Fragments are matched by position (fragment 1 vs fragment 1, fragment 2 vs fragment 2, etc.). This tool does not detect fragment reordering or track moved sections. If the documents have very different structures (different fragment counts, major reordering), the output will show extensive changes.
Best used for comparing documents with the same basic structure where you made local edits (word changes, clause deletions, appended sections, table cell modifications).
Output Format
Each fragment is reported with its change status.
Paragraphs::
Fragment 1: unchanged
Fragment 2: modified
- shall deliver
+ must deliver immediately
Fragment 3: unchanged
Fragment 5: deleted (only in original)
- This clause is removed.
Fragment 10: added (only in modified)
+ This is a new clause.Tables::
Table 56: modified
Cell 56.2.2: modified
- Gwendolyn Mahon, M.Sc., Ph.D
+ John H. Smith, Ph.D.
Table 57: unchanged
Table 58: dimensions changed (3x2 → 4x2)Lines starting with - show deleted text, + shows inserted text.
Unchanged fragments are listed but their text is omitted for brevity.
For tables, each modified cell is shown with its cell ID (table_id.row.col) followed by the word-level diff of the cell content.
Difference from extract_fragments
extract_fragmentsshows the plain text of a single document (paragraphs, headers, footers, tables). Pre-existing tracked changes cause a hard rejection.diff_fragmentscompares two separate documents and computes the differences between their plain text (ignoring any tracked changes)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| modified_path | Yes | Absolute path to the modified .docx file. | |
| original_path | Yes | Absolute path to the original .docx file. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |