# Python Markdown to DOCX libraries

Python Markdown to DOCX libraries convert Markdown text into Microsoft Word documents. A converter either calls Pandoc, a separate document conversion tool, or writes the Word file through its own document model. These libraries let report generators and AI agents deliver Markdown drafts as Word files.

## Popularity

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [pypandoc](#pypandoc) | 4.5M | 1.2K | Mar 2026 | MIT |
| [pandoc](#pandoc) | 871.4K | 188 | Aug 2024 | MIT |
| [Aspose.Words](#aspose-words) | 465.1K | Not on GitHub | Nov 2026 | Proprietary |
| [Spire.Doc](#spire-doc) | 115.1K | Not on GitHub | Sep 2026 | Proprietary |
| [md2docx-python](#mdtwodocx-python) | 13.6K | Not on GitHub | Mar 2025 | MIT |
| [Markdown2docx](#markdowntwodocx) | 12.8K | Not on GitHub | Jan 2022 | MIT |
| [md-to-word-docx](#md-to-word-docx) | 9.3K | 18 | Nov 2026 | MIT |
| [python-md2docx](#python-mdtwodocx) | 3.3K | 1 | Mar 2026 | MIT |

Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

[pypandoc](#pypandoc) has the most monthly downloads in this comparison, at 4.5M.

## Capabilities

| Library | Imports tables | Imports images | Configures Word formatting |
| --- | --- | --- | --- |
| [pypandoc](#pypandoc) | Via plugin | Via plugin | Via plugin |
| [pandoc](#pandoc) | Via plugin | Via plugin | Via plugin |
| [Aspose.Words](#aspose-words) | Yes | Yes | Yes |
| [Spire.Doc](#spire-doc) | Undocumented | Undocumented | Yes |
| [md2docx-python](#mdtwodocx-python) | No | No | No |
| [Markdown2docx](#markdowntwodocx) | Undocumented | Undocumented | Undocumented |
| [md-to-word-docx](#md-to-word-docx) | Yes | Yes | Yes |
| [python-md2docx](#python-mdtwodocx) | Yes | Yes | Yes |

## Libraries

### pypandoc

[GitHub](https://github.com/JessicaTegner/pypandoc) · [PyPI](https://pypi.org/project/pypandoc) · [Docs](https://raw.githubusercontent.com/JessicaTegner/pypandoc/master/README.md)

Converts Markdown files to Word documents through the Pandoc executable.

- Downloads / mo: 4.5M
- Stars: 1.2K
- Last release: 1.17
- License: MIT
- Capabilities: [From the pypandoc docs](https://raw.githubusercontent.com/JessicaTegner/pypandoc/master/README.md)

**Strengths**

- **Reuses Word document styles.** A reference DOCX supplies styles, margins, headers, and footers.
- **Combines Markdown files.** Convert chapter files into one Word document using a file pattern.

**Watch out for**

- **Requires Pandoc.** Install Pandoc separately or use the bundled pypandoc_binary distribution.
- **Ignores reference document content.** Reference DOCX files supply formatting rather than reusable document text.

```sh
pip install pypandoc
```

**MODSetter/SurfSense** (16.8K stars)

[MODSetter/SurfSense](https://github.com/MODSetter/SurfSense) 

```python
def _pandoc_to_tempfile(output_format: str, extra_args: list[str]) -> bytes:
            """Convert via pandoc to a binary format using a temp file."""
            fd, tmp_path = tempfile.mkstemp(suffix=f".{output_format}")
            os.close(fd)
            try:
                pypandoc.convert_text(
                    markdown_content,
                    output_format,
                    format=input_fmt,
                    extra_args=extra_args,
                    outputfile=tmp_path,
                )
                with open(tmp_path, "rb") as f:
                    return f.read()
            finally:
                os.unlink(tmp_path)

```

[surfsense_backend/app/routes/reports_routes.py](https://github.com/MODSetter/SurfSense/blob/4e9225b1cd31abb7ee902425cc444fef0e4bbb86/surfsense_backend/app/routes/reports_routes.py#L530-L545) · [More projects using pypandoc →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20that%20use%20pypandoc&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```python
import pypandoc

output = pypandoc.convert_file('somefile.md', 'docx', outputfile="somefile.docx")

```

From [README.md](https://raw.githubusercontent.com/JessicaTegner/pypandoc/master/README.md)

### pandoc

[GitHub](https://github.com/boisgera/pandoc) · [PyPI](https://pypi.org/project/pandoc) · [Docs](https://boisgera.github.io/pandoc/api/)

Represents Pandoc documents in Python.

- Downloads / mo: 871.4K
- Stars: 188
- Last release: 2.4
- License: MIT
- Capabilities: [From the pandoc docs](https://boisgera.github.io/pandoc/api/)

```sh
pip install --upgrade pandoc
```

**Quickstart**

```python
import pandoc

doc = pandoc.read("Hello world!")
pandoc.write(doc, file="output.docx", format="docx")

```

From [api.md](https://boisgera.github.io/pandoc/api/) · [Find projects using pandoc →](https://dashboard.exa.ai/playground/search?q=pandoc%20GitHub%20projects)

### Aspose.Words

[PyPI](https://pypi.org/project/aspose-words) · [Docs](https://blog.aspose.com/words/convert-markdown-to-word-in-python/)

Loads Markdown into editable Word documents and saves DOCX output.

- Downloads / mo: 465.1K
- Last release: 26.11.0
- License: Proprietary
- Capabilities: [From the Aspose.Words docs](https://blog.aspose.com/words/convert-markdown-to-word-in-python/)

**Strengths**

- **Converts Markdown directly.** Load Markdown with Document and save the result as DOCX.
- **Copies Word template styles.** Use copy_styles_from_template to reuse another document's styles.

**Watch out for**

- **Trial adds watermarks.** Apply a license to remove evaluation marks and trial size limits.

```sh
pip install aspose-words
```

**Quickstart**

```python
import aspose.words as aw

doc = aw.Document("Input.md")
doc.save("Output.docx")

```

From [markdown-to-word.md](https://products.aspose.com/words/python-net/conversion/markdown-to-word/) · [Find projects using Aspose.Words →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20that%20use%20aspose-words&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

### Spire.Doc

[PyPI](https://pypi.org/project/Spire.Doc) · [Docs](https://www.e-iceblue.com/Knowledgebase/Python/Spire.Doc-for-Python/Program-Guide/Conversion/Python-Convert-Markdown-to-Word-or-Word-to-Markdown.html)

Loads Markdown documents and saves them in Word formats.

- Downloads / mo: 115.1K
- Last release: 14.9.1
- License: Proprietary
- Capabilities: [From the Spire.Doc docs](https://www.e-iceblue.com/Knowledgebase/Python/Spire.Doc-for-Python/Program-Guide/Conversion/Python-Convert-Markdown-to-Word-or-Word-to-Markdown.html)

**Strengths**

- **Converts Markdown directly.** Load Markdown with Document.LoadFromFile and save it as DOCX.
- **Exports Word back to Markdown.** Convert DOCX and DOC files to Markdown using SaveToFile.

**Watch out for**

- **Temporary license removes trial limits.** Request a temporary license for evaluation without watermarks or restrictions.

```sh
pip install Spire.Doc
```

**Quickstart**

```python
from spire.doc import *
from spire.doc.common import *

# Create an object of the Document class
document = Document()
# Load a Markdown file
document.LoadFromFile("input.md")

# Save the Markdown file to a Word DOCX file
document.SaveToFile("MdToDocx.docx", FileFormat.Docx)

```

From [Python-Convert-Markdown-to-Word-or-Word-to-Markdown.html](https://www.e-iceblue.com/Knowledgebase/Python/Spire.Doc-for-Python/Program-Guide/Conversion/Python-Convert-Markdown-to-Word-or-Word-to-Markdown.html) · [Find projects using Spire.Doc →](https://dashboard.exa.ai/playground/search?q=Python%20projects%20that%20use%20Spire.Doc&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

### md2docx-python

[GitHub](https://github.com/shloktech/md2docx-python) · [PyPI](https://pypi.org/project/md2docx-python) · [Docs](https://pypi.org/project/md2docx-python/)

Converts Markdown to Word.

- Downloads / mo: 13.6K
- Last release: 1.0.0
- License: MIT
- Capabilities: [From the md2docx-python docs](https://pypi.org/project/md2docx-python/)

```sh
pip install md2docx-python
```

**Quickstart**

```python
from md2docx_python.src.md2docx_python import markdown_to_word
markdown_file = "sample_files/amazon_case_study.md"
word_file = "sample_files/amazon_case_study.docx"
markdown_to_word(markdown_file, word_file)

```

From [Readme.md](https://pypi.org/project/md2docx-python/) · [Find projects using md2docx-python →](https://dashboard.exa.ai/playground/search?q=md2docx-python%20GitHub%20projects)

### Markdown2docx

[PyPI](https://pypi.org/project/Markdown2docx) · [Docs](https://pypi.org/project/Markdown2docx/)

Converts Markdown to DOCX with token and command output substitution.

- Downloads / mo: 12.8K
- Last release: 0.1.0
- License: MIT
- Capabilities: [From the Markdown2docx docs](https://pypi.org/project/Markdown2docx/)

```sh
pip install Markdown2docx
```

**Quickstart**

```python
from Markdown2docx import Markdown2docx
project = Markdown2docx('README')
project.eat_soup()
project.save()

```

From [README.md](https://pypi.org/project/Markdown2docx/) · [Find projects using Markdown2docx →](https://dashboard.exa.ai/playground/search?q=Markdown2docx%20GitHub%20projects)

### md-to-word-docx

[GitHub](https://github.com/ls-open/md-to-word) · [PyPI](https://pypi.org/project/md-to-word-docx) · [Docs](https://github.com/ls-open/md-to-word/blob/main/src/md_to_word/resources/manual_en.md)

Compiles Markdown to Word with declared typography, native equations, tables, cross-references, and bibliographies.

- Downloads / mo: 9.3K
- Stars: 18
- Last release: 3.3.3
- License: MIT
- Capabilities: [From the md-to-word-docx docs](https://github.com/ls-open/md-to-word/blob/main/src/md_to_word/resources/manual_en.md)

```sh
pip install md-to-word-docx
```

**Quickstart**

```python
from md_to_word import export

result = export("稿件.md", "稿件.docx", format="format.txt")

```

From [README.md](https://pypi.org/pypi/md-to-word-docx/3.3.3/json) · [Find projects using md-to-word-docx →](https://dashboard.exa.ai/playground/search?q=md-to-word-docx%20GitHub%20projects)

### python-md2docx

[GitHub](https://github.com/suqingdong/md2docx) · [PyPI](https://pypi.org/project/python-md2docx) · [Docs](https://pypi.org/project/python-md2docx/)

Converts Markdown to DOCX.

- Downloads / mo: 3.3K
- Stars: 1
- Last release: 1.0.5
- License: MIT
- Capabilities: [From the python-md2docx docs](https://pypi.org/project/python-md2docx/)

```sh
pip install python-md2docx
```

**Quickstart**

```python
from md2docx.core import MD2DOCX
MD2DOCX().convert('tests/demo.md', output_file='tests/demo.docx')

```

From [README.md](https://pypi.org/project/python-md2docx/) · [Find projects using python-md2docx →](https://dashboard.exa.ai/playground/search?q=python-md2docx%20GitHub%20projects)

## FAQ

### Which Python Markdown to DOCX library should I use?

[pypandoc](#pypandoc) suits most conversions and applies styles from a reference document. [Aspose.Words](#aspose-words) and [Spire.Doc](#spire-doc) suit teams that want a commercial document API without Pandoc. [md-to-word-docx](#md-to-word-docx) suits documents with equations, cross-references, and bibliographies.

### How do I convert Markdown to Word in Python?

[pypandoc](#pypandoc) passes the Markdown file to Pandoc and writes a DOCX file. A reference document supplies the styles and document properties for the output.

### What is pypandoc?

[pypandoc](#pypandoc) is a thin Python wrapper for Pandoc, the document converter. It passes Pandoc options such as a reference document through to the conversion.

### Does Pandoc keep math equations when converting Markdown to DOCX?

Pandoc writes math from Markdown as native Word equations wherever its Markdown reader supports the math syntax.

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Python Markdown to DOCX libraries Pandoc Aspose.Words Spire.Doc all2md official documentation conversion templates",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
