Skip to main content

Edit docx with python

Project description

docx-editor

Release Build status codecov Commit activity License

Pure Python library for Word document track changes and comments, without requiring Microsoft Word.

Note: The PyPI package is named docx-editor because docx-edit was too similar to an existing package.

Features

  • Track Changes: Replace, delete, and insert text with revision tracking
  • 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 defusedxml for secure XML parsing

Installation

pip install docx-editor

Quick Start

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()

Claude Code Skill

This repo includes a skill for Claude Code that enables AI-assisted Word document editing.

This skill extends the original Anthropic docx skill which requires Claude to manually manipulate OOXML. Instead, this skill 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.

Install the skill

# 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-editor

Once installed, Claude Code can help you edit Word documents with track changes, comments, and revisions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docx_editor-0.0.2.tar.gz (345.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docx_editor-0.0.2-py3-none-any.whl (32.9 kB view details)

Uploaded Python 3

File details

Details for the file docx_editor-0.0.2.tar.gz.

File metadata

  • Download URL: docx_editor-0.0.2.tar.gz
  • Upload date:
  • Size: 345.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for docx_editor-0.0.2.tar.gz
Algorithm Hash digest
SHA256 21e7a9c9d1db5e6805321ec8afc5e3c140349ffeec6d2b99b032ba51b6b9faae
MD5 227e27299c6689bbc44d562332cf619f
BLAKE2b-256 6f11bce908e8cadd5ca0693385fcdfa8834e46f6aac588f5a576282f68768797

See more details on using hashes here.

File details

Details for the file docx_editor-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: docx_editor-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 32.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for docx_editor-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 73843fd6d2eb9dfb1456aac8f87f0b841ed00c165401c7b4d27117661e055d12
MD5 f89b651707f0b51fe4ec50a38d201c05
BLAKE2b-256 d7875356f2ed82c24ea737f17c4d7d095f9439b96d4755e1094799ccdcc636bc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page