Package Information
Downloads: 529 weekly / 1,187 monthly
Latest Version: 0.4.3
Author: n8n-docx-diff
Available Nodes
Documentation
n8n-nodes-docx-diff
Generate a DOCX with tracked changes (w:ins/w:del) from two DOCX inputs so Google Docs shows Suggestions and Microsoft Word shows tracked changes.
What it does
- Produces a DOCX that preserves the revised document structure (styles, numbering, rels, images)
- Highlights differences at paragraph/run level
- Handles: body paragraphs, lists/numbering, tables, text boxes, SDT (content controls), hyperlinks
- Omits bookmarks (to avoid distractions in Google Docs)
- Optional headers/footers diffing is implemented internally and can be enabled
Input/Output
- Inputs: two incoming items to the node (Original on input 1, Revised on input 2), each with one DOCX binary. If multiple binaries exist, the node picks by DOCX MIME type or .docx filename, otherwise errors with choices.
- Output: a single item containing binary diff.docx and a warnings array in json.
Key behaviors
- Lists: pPr/numPr are preserved; insertions wrap only textual runs; deletions synthesize a paragraph with original pPr and deleted runs; modifications wrap changed run spans
- Tables, text boxes, SDT: paragraphs inside are diffed with the same engine
- Hyperlinks preserved; bookmarks omitted
- Existing tracked revisions: existing ins/del/move* are stripped during comparison (ignore). A strict mode exists internally to fail if present
Recent improvements
- Style/List-aware alignment keys to reduce cross-style mismatches and align bullets at the correct levels
- Fallback alignment mode (text-only keys) to avoid pathological non-matching
- Similarity heuristic to choose paragraph-level vs inline run-level diffs
- Punctuation-aware tiny-gap merging to avoid noisy equal islands
- Strict same-level bullet pairing (requires same ilvl; if numId differs, require higher similarity)
- Numbering-only change suppression (when text is equal but numbering changes)
- Stable timestamp mode for byte-identical outputs across runs in CI
Options (defaults shown)
- granularity: 'word' | 'char' (default: 'word')
- listIdAlignmentMode: 'ignore-numId' | 'exact' (UI stub)
- styleChangeEditMode: 'paragraph' | 'inline' (UI stub)
- suppressWhitespaceOnly: boolean (default: true)
- includeLists/includeTables/includeTextBoxes/includeHeadersFooters: boolean (defaults: lists/tables/textboxes true; headers/footers false)
- existingTrackedRevisions: 'ignore' | 'fail' (default: 'ignore')
- limits: { maxTotalUnzippedBytes, maxEntries, maxEntrySize, maxTokensPerParagraph }
- mergeSmallEqualGapsThreshold: number (default: 1)
- mergeSmallPunctGapsThreshold: number (default: 1)
- punctuationClass: string (default: ",.;:!?")
- unicodeNormalization: 'off' | 'NFC' | 'NFKC' (default: 'NFC')
- collapseNBSP: boolean (default: true)
- normalizeQuotes: boolean (default: true)
- paragraphAligner: 'lcs' | 'hybrid' (default: 'hybrid')
- listAwareAlignment: boolean (default: true)
- styleAwareAlignment: boolean (default: true)
- modifiedParagraphSimilarityThreshold: number (default: 0.3)
- timestampMode: 'now' | 'fixed' (default: 'now')
- fixedTimestamp: ISO string used when timestampMode is 'fixed' (default: '2000-01-01T00:00:00.000Z' if not supplied)
NormalizationProfile
- Shared with HTML→DOCX node for consistent normalization used in matching/alignment only.
- Defaults:
{
"punctuation": "conservative",
"whitespacePolicy": "collapse",
"collapseNBSP": true,
"normalizeQuotes": true,
"unicodeNormalization": "NFC"
}
Minimal DOCX constraints
- Pre/post-diff passes aim to keep only w:b/w:i runs and w:pStyle/w:numPr paragraph properties; remove bookmarks; collapse empties. List and hyperlink wrappers are preserved.
Usage (self-hosted n8n)
- Install this Community Node package and use the node "DOCX Track-Diff"
- Connect two upstream nodes producing DOCX binaries to the two inputs
- Execute the workflow; the resulting diff.docx binary shows Suggestions in Google Docs and tracked changes in Word
Development
- Node 20+
- Install: npm ci
- Lint: npm run lint
- Build: npm run build
- Test: npm test
License
- MIT