Lossless DOCX <-> Markdown conversion preserving Word comment threads
Project description
docx-md-comments
docx-md-comments is a DOCX to Markdown converter and Markdown to DOCX converter focused on one hard problem: preserving Microsoft Word comments through roundtrip edits.
It is built for workflows where you:
- start with a Word
.docxcontaining comments - edit content and comments in Markdown (manually or with an LLM)
- convert back to Word without losing comment structure
LLM-focused benefit:
- LLMs can draft or rewrite content
- LLMs can add new comments and threaded replies in Markdown
- those comments/replies are reconstructed as native Word comment threads on export
At A Glance
| Capability | Supported |
|---|---|
| DOCX -> Markdown conversion | Yes |
| Markdown -> DOCX conversion | Yes |
| Comment anchors | Preserved |
| Threaded replies | Preserved |
| Comment state (active/resolved) | Preserved |
| Native Word comment thread reconstruction | Yes |
| LLM-authored comments and replies roundtrip back to Word threads | Yes |
Why This Is Useful
Most generic converters drop or flatten comment metadata. This project is focused on Word review workflows, so comments remain usable after conversion.
Common use cases:
- legal, scientific, or editorial review drafts with heavy comment threading
- LLM-assisted editing where the model also writes comments/replies for reviewers
- roundtrip pipelines where Word comments must survive intact
Before You Start
Requirements:
- Python 3.10+
- Pandoc installed and available on
PATH
Install Pandoc:
- macOS:
brew install pandoc - Ubuntu/Debian:
sudo apt-get install pandoc - Windows (PowerShell):
choco install pandoc -y
Install
Recommended (pipx, isolated app install):
pipx install docx-md-comments
Alternative (pip):
python -m pip install docx-md-comments
Installed commands:
dmcdocx-commentsdocx2md/d2mmd2docx/m2d
Update To Latest Version
If installed with pipx:
pipx upgrade docx-md-comments
If installed with pip:
python -m pip install --upgrade docx-md-comments
Quick Start
Convert Word to Markdown:
dmc draft.docx
Creates draft.md.
Convert Markdown back to Word:
dmc draft.md
Creates draft.docx.
LLM Editing Workflow
- Convert reviewed Word document to Markdown:
dmc reviewed.docx
- Edit
reviewed.mdmanually or with an LLM. The LLM can update prose and add root comments or threaded replies. - Convert back to Word:
dmc reviewed.md
- Open
reviewed.docxin Word and continue normal comment-based review.
Command Variants
DOCX -> Markdown:
docx-comments draft.docx
docx2md draft.docx
d2m draft.docx
Markdown -> DOCX:
md2docx draft.md
m2d draft.md
Explicit input/output paths
DOCX -> Markdown:
docx2md draft.docx -o draft.md
d2m draft.docx -o draft.md
dmc docx2md draft.docx -o draft.md
Markdown -> DOCX:
md2docx draft.md -o draft.docx
m2d draft.md -o draft.docx
dmc md2docx draft.md -o draft.docx
Use a reference Word document for styling:
md2docx draft.md --ref original.docx -o final.docx
m2d draft.md -r original.docx -o final.docx
--ref maps to Pandoc --reference-doc.
Pass-through Pandoc arguments (advanced)
Unknown flags are passed through to Pandoc:
docx2md draft.docx -o draft.md --extract-media=media
dmc md2docx draft.md --reference-doc=template.docx
Limitations
- Tracked Changes: Word revisions are not preserved through roundtrip. Resolve them in Word first.
- Formatting: This project prioritizes comment fidelity. Very complex layouts may not roundtrip perfectly.
Help
dmc --help
docx2md --help
md2docx --help
For Contributors: Testing
Run full suite:
make test
Roundtrip-focused tests only:
make test-roundtrip
make test also writes:
artifacts/out_test.mdartifacts/out_test.docx
Report Issues
Please open bugs/feature requests at:
https://github.com/Pascal-Kueng/docx-md-comments/issues
When reporting a conversion bug, include:
- input sample (or minimal repro)
- command used
- expected vs actual behavior (Word view)
- failing
failure_bundlepath if tests failed
Technical Notes (Brief)
- Marker style uses
///C<ID>.START///////C<ID>.END///(optional==...==wrapper). - Reply relationships are reconstructed as native Word threads (
commentsExtended.xmlparaIdParent+ story markers). - Validation fails fast on malformed marker edits with line-specific diagnostics.
For maintainer details, see AGENTS.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file docx_md_comments-1.0.1.tar.gz.
File metadata
- Download URL: docx_md_comments-1.0.1.tar.gz
- Upload date:
- Size: 55.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
286f0093ad70c2450e379e08a2164a58febf79bec78082584aed16c20cf622ed
|
|
| MD5 |
182d3ea5aa613abdb72caade013b9593
|
|
| BLAKE2b-256 |
69314d2282c975003d49b6b9779c867bf776ac08a0596c3bfa995504095fb2db
|
Provenance
The following attestation bundles were made for docx_md_comments-1.0.1.tar.gz:
Publisher:
publish.yml on Pascal-Kueng/docx-md-comments
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docx_md_comments-1.0.1.tar.gz -
Subject digest:
286f0093ad70c2450e379e08a2164a58febf79bec78082584aed16c20cf622ed - Sigstore transparency entry: 955654248
- Sigstore integration time:
-
Permalink:
Pascal-Kueng/docx-md-comments@ae60c2072f356faddd8d4ca2d64b8cdf533b7789 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Pascal-Kueng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ae60c2072f356faddd8d4ca2d64b8cdf533b7789 -
Trigger Event:
release
-
Statement type:
File details
Details for the file docx_md_comments-1.0.1-py3-none-any.whl.
File metadata
- Download URL: docx_md_comments-1.0.1-py3-none-any.whl
- Upload date:
- Size: 41.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c25730a0719435591268fff9993847fa012878659f8491ac8554f87cd4ab0175
|
|
| MD5 |
ef7e762ed561b5a6ca6f08f3046723c2
|
|
| BLAKE2b-256 |
ab6ea307593ca09033fc39ed9b068682644be5c76d337b2a460a1d9c41d7a11b
|
Provenance
The following attestation bundles were made for docx_md_comments-1.0.1-py3-none-any.whl:
Publisher:
publish.yml on Pascal-Kueng/docx-md-comments
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
docx_md_comments-1.0.1-py3-none-any.whl -
Subject digest:
c25730a0719435591268fff9993847fa012878659f8491ac8554f87cd4ab0175 - Sigstore transparency entry: 955654277
- Sigstore integration time:
-
Permalink:
Pascal-Kueng/docx-md-comments@ae60c2072f356faddd8d4ca2d64b8cdf533b7789 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Pascal-Kueng
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ae60c2072f356faddd8d4ca2d64b8cdf533b7789 -
Trigger Event:
release
-
Statement type: