DOCX to Markdown for Python
Convert Word documents to Markdown, with individual pages, headers, footers, comments, and tracked changes.
Install
Use Python 3.11 or later. Install the package with pip:
pip install docx-to-markdown
Usage
Convert a file and read its document and page output:
from docx_to_markdown import convert
result = convert("contract.docx")
print(result.markdown)
for page in result.pages:
print(f"Page {page.number}", page.markdown)
print(page.header_markdown, page.footer_markdown)
result.markdown contains the document body; headers and footers stay in result.pages. Input can be a file path, bytes, or a binary file object.
Options
Enable images, supply font files, and choose a tracked-change view:
result = convert(
"contract.docx",
images=True,
fonts="fonts/",
google_fonts=True,
display_mode="proposed",
)
result.write("out/") # document.md, document.json, media/
images=Trueextracts images;images="html"also preserves displayed sizes.fontsaccepts font files or directories. Common Word font substitutes are bundled.google_fonts=Truefetches missing fonts from a pinned Google Fonts catalog (requires network access). Usegoogle_font_families()to list supported families andresult.missing_fontsto check what still needs local font files.display_modeselects tracked changes:"all-markup"(default),"proposed"(accepted view), or"original"(rejected view).
Comments and tracked changes are available in result.comments and result.tracked_changes. Page breaks can differ from Word; check result.warnings for conversion issues.
Batch conversion
Reuse one converter process for multiple files:
from pathlib import Path
from docx_to_markdown import Converter
with Converter() as converter:
for path in Path("contracts").glob("*.docx"):
result = converter.convert(path)
result.write(Path("output") / path.stem)
Command line
Write Markdown to standard output, save a file, or export a bundle:
docx-to-markdown contract.docx # Markdown to stdout
docx-to-markdown contract.docx -o contract.md
docx-to-markdown contract.docx --json
docx-to-markdown *.docx --bundle out/ --images
Documentation · Try the demo · PyPI · Changelog
License
Apache 2.0. Bundled dependencies and fonts retain their own licenses; notices are included in the package.
Release files for docx-to-markdown 2.22.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Reset | |||
|---|---|---|---|---|
| docx_to_markdown-2.22.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details |
| docx_to_markdown-2.22.0-py3-none-manylinux_2_17_x86_64.whl | Python 3 | none | Linux glibc 2.17+ x86-64 | Details |
| docx_to_markdown-2.22.0-py3-none-manylinux_2_17_aarch64.whl | Python 3 | none | Linux glibc 2.17+ ARM64 | Details |
| docx_to_markdown-2.22.0-py3-none-macosx_13_0_x86_64.whl | Python 3 | none | macOS 13.0+ x86-64 | Details |
| docx_to_markdown-2.22.0-py3-none-macosx_13_0_arm64.whl | Python 3 | none | macOS 13.0+ ARM64 | Details |
Total release size: 191.8 MB
Release files / docx_to_markdown-2.22.0-py3-none-win_amd64.whl
| Download URL | docx_to_markdown-2.22.0-py3-none-win_amd64.whl |
|---|---|
| Size | 44.7 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b03cf969ddbccc9b403e707ec78cc0897420bdfb7f202ecbcd8af0bccd2cd6f6
|
|
BLAKE2b-256 checksum How to use checksums |
26fcc772e7e8d1b7ab535af1ec40eb2e4611c3a16970dae1e68a212dc435fb39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / docx_to_markdown-2.22.0-py3-none-manylinux_2_17_x86_64.whl
| Download URL | docx_to_markdown-2.22.0-py3-none-manylinux_2_17_x86_64.whl |
|---|---|
| Size | 41.6 MB |
| Tags | Linux glibc 2.17+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
fc843d38db8603bd26fc3bf9a5eb3d440d24acbd30b2de0d6647eb4820c2b665
|
|
BLAKE2b-256 checksum How to use checksums |
423dd1d71416d926096cbb2c41fb32566f32f09814eadbffbc187fdb21090071
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / docx_to_markdown-2.22.0-py3-none-manylinux_2_17_aarch64.whl
| Download URL | docx_to_markdown-2.22.0-py3-none-manylinux_2_17_aarch64.whl |
|---|---|
| Size | 41.5 MB |
| Tags | Linux glibc 2.17+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
6a18f671519151ac2485acde49d1888e6a3e97c122774e31aeae1ac88ba2c6a1
|
|
BLAKE2b-256 checksum How to use checksums |
a52bbfc2bbc9c06716e20ef9c897399af3813ab7e8d9951c5208754c7b02dd32
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / docx_to_markdown-2.22.0-py3-none-macosx_13_0_x86_64.whl
| Download URL | docx_to_markdown-2.22.0-py3-none-macosx_13_0_x86_64.whl |
|---|---|
| Size | 33.3 MB |
| Tags | Python 3 macOS 13.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
bf24dc674eba0642a16bc5e126162a21b206dc8586d8e2e356116a5988a92fae
|
|
BLAKE2b-256 checksum How to use checksums |
340c85a25ec320d7b5bd6256dfda3a8548417a4654ca4d91d8cc73473a532c5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency logRelease files / docx_to_markdown-2.22.0-py3-none-macosx_13_0_arm64.whl
| Download URL | docx_to_markdown-2.22.0-py3-none-macosx_13_0_arm64.whl |
|---|---|
| Size | 30.6 MB |
| Tags | Python 3 macOS 13.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
506ff3db23e534f6bae0772953703beea1556f2127f3f01cd71d76e04d8aee4a
|
|
BLAKE2b-256 checksum How to use checksums |
16aabeb98a00f9afa7d5f7903150160c012e6310d73758a0b918f1eaa24550b1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.
Transparency log