Pure Python library for Word document track changes and comments, without requiring Microsoft Word.
Note: The PyPI package is named
docx-editorbecausedocx-editwas too similar to an existing package.
- Github repository: https://github.com/pablospe/docx-editor/
- Documentation: https://pablospe.github.io/docx-editor/
- Track Changes: Replace, delete, and insert text with revision tracking
- Cross-Boundary Editing: Find and replace text spanning multiple XML elements and revision boundaries
- Mixed-State Editing: Atomic decomposition for text spanning
<w:ins>/<w:del>boundaries - Comments: Add, reply, resolve, and delete comments
- Revision Management: List, accept, and reject tracked changes
- Cross-Platform: Works on Linux, macOS, and Windows
- No Dependencies: Only requires
defusedxmlfor secure XML parsing
pip install docx-editorThis repo includes a plugin for Claude Code that enables AI-assisted Word document editing.
This plugin extends the original Anthropic docx skill which requires Claude to manually manipulate OOXML. Instead, this plugin provides an interface (docx-editor) that handles all the complexity—Claude just calls simple Python methods like doc.replace() or doc.add_comment(), making document editing significantly faster and less error-prone.
# Add the marketplace
/plugin marketplace add pablospe/docx-editor
# Install the plugin
/plugin install docx-editor@docx-editor-marketplace
# Install dependencies
pip install docx-editor python-docx# Install dependencies
pip install docx-editor python-docx
# Copy skill to Claude Code skills directory
git clone https://github.com/pablospe/docx-editor /tmp/docx-editor
mkdir -p ~/.claude/skills
cp -r /tmp/docx-editor/skills/docx ~/.claude/skills/
rm -rf /tmp/docx-editorOnce installed, Claude Code can help you edit Word documents with track changes, comments, and revisions.
from docx_editor import Document
with Document.open("contract.docx") as doc:
# Track changes
doc.replace("30 days", "60 days")
doc.insert_after("Section 5", "New clause")
doc.delete("obsolete text")
# Comments
doc.add_comment("Section 5", "Please review")
# Revision management
revisions = doc.list_revisions()
doc.accept_revision(revision_id=1)
doc.save()Text in Word documents with tracked changes can span revision boundaries. docx-editor handles this transparently:
from docx_editor import Document
with Document.open("reviewed.docx") as doc:
# Get visible text (inserted text included, deleted excluded)
text = doc.get_visible_text()
# Find text across element boundaries
match = doc.find_text("Aim: To")
if match and match.spans_boundary:
print("Text spans a revision boundary")
# Replace works even across revision boundaries
doc.replace("Aim: To", "Goal: To")
doc.save()