Skip to main content

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=True extracts images; images="html" also preserves displayed sizes.
  • fonts accepts font files or directories. Common Word font substitutes are bundled.
  • google_fonts=True fetches missing fonts from a pinned Google Fonts catalog (requires network access). Use google_font_families() to list supported families and result.missing_fonts to check what still needs local font files.
  • display_mode selects 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.21.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for docx-to-markdown 2.21.1
File
docx_to_markdown-2.21.1-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
docx_to_markdown-2.21.1-py3-none-manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
docx_to_markdown-2.21.1-py3-none-manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
docx_to_markdown-2.21.1-py3-none-macosx_13_0_x86_64.whl Python 3 none macOS 13.0+ x86-64 Details
docx_to_markdown-2.21.1-py3-none-macosx_13_0_arm64.whl Python 3 none macOS 13.0+ ARM64 Details

Total release size: 191.6 MB

Release files / docx_to_markdown-2.21.1-py3-none-win_amd64.whl

Download URL docx_to_markdown-2.21.1-py3-none-win_amd64.whl
Size 44.7 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
2c30928f179fc37c0bbd8b8432a59de008add641a75cf488a6ca8bab4419542b
BLAKE2b-256 checksum
How to use checksums
05c493df68249c8a409eb91b61f795a89931c0b53b1ddc755d631328f839c28a
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 21, 2026.

Transparency log

Release files / docx_to_markdown-2.21.1-py3-none-manylinux_2_17_x86_64.whl

Download URL docx_to_markdown-2.21.1-py3-none-manylinux_2_17_x86_64.whl
Size 41.5 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
0e0b73089e7ee58e0a460265b706263731aa395d770e33ec287e95df87c8334f
BLAKE2b-256 checksum
How to use checksums
561cad2d3a743dd2dae85e2416c621c49ac36f5814a2f18128285dc6c90ee0b1
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 21, 2026.

Transparency log

Release files / docx_to_markdown-2.21.1-py3-none-manylinux_2_17_aarch64.whl

Download URL docx_to_markdown-2.21.1-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
f8f0c4df5700fe97a78f27c07d7ffc160ff249c3b5814ea131451a858cf21f56
BLAKE2b-256 checksum
How to use checksums
876038eb2a17f50e41991584eea6d48524a3e05f495cab1d016168b13659650e
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 21, 2026.

Transparency log

Release files / docx_to_markdown-2.21.1-py3-none-macosx_13_0_x86_64.whl

Download URL docx_to_markdown-2.21.1-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
285d0839ea2a4a9183493cea32bd9278a94acf4116c8dd0cfb95077109d10aeb
BLAKE2b-256 checksum
How to use checksums
c99b961b5a228925304e17a319b0c534e72abf1d19842cdf3da873120f471963
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 21, 2026.

Transparency log

Release files / docx_to_markdown-2.21.1-py3-none-macosx_13_0_arm64.whl

Download URL docx_to_markdown-2.21.1-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
cd6ab0eb0528cdd22c638d3bb9582565c5d737113892977239fd9c8a66504f8c
BLAKE2b-256 checksum
How to use checksums
fb12cc2e1b4928d8691d67048ec6b49683e77a63a1613f2201745bc047c5a469
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 21, 2026.

Transparency log

Release history Release notifications | RSS feed

2.23.0

5 release files

2.22.0

5 release files

This release

2.21.1 This release

5 release files

2.21.0

5 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page