# python-docx

> Create and modify Word documents with Python

Source: https://talira.ai/catalog/python-docx-tj4sn5d1
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [documents / office](https://talira.ai/categories/documents/office), [languages / python](https://talira.ai/categories/languages/python)
- Licence: MIT[^3][^4]
- Pricing: Free and open source[^3]
- Pricing notes: MIT licensed and free.
- Free tier: yes[^3]
- Self-hostable: yes[^5]
- Creator: Steve Canny (scanny)

python-docx is a Python library for reading, creating and updating [Microsoft Word](https://talira.ai/catalog/microsoft-word-pb8ghn21.md) 2007+ (.docx) files without Word installed. It opens an existing document or starts a new one and works through an object model of paragraphs, runs and fonts, tables and cells, sections and page setup, headers and footers, styles, inline pictures and, since 1.2.0, comments; anything it doesn't understand is kept as-is when the file is saved. Libraries such as [docxtpl](https://talira.ai/catalog/docxtpl-yhjaa0ty.md) build on it, and [docx2python](https://talira.ai/catalog/docx2python-tdeqb4ak.md) is a read-only alternative for pulling text, tables and form values out of a document.

## Links

- GitHub: https://github.com/python-openxml/python-docx
- Docs: https://python-docx.readthedocs.io/en/latest/

## Problems it solves

- read the values people typed into the tables of a Word form and load them into a database from Python
- generate Word reports from a Python script without Microsoft Office installed on the server
- loop over every paragraph in a .docx and find the ones that use the Heading 2 style
- change the font, size and colour of specific runs of text in an existing Word document
- add a table with a header row to a Word document and fill it from a list of dicts
- insert a chart image into a Word document at a fixed width from a Python job
- set the page orientation, margins and headers and footers of a .docx programmatically
- add review comments to paragraphs in a Word file from code
- read the author, title and last-modified-by properties of hundreds of .docx files
- replace a placeholder word in a Word document while keeping the rest of its formatting
- build a Word document on a Linux server in a Django or Flask app and send it to the browser

## Features

- open existing .docx files or create new ones, and save them
- paragraphs, runs and character formatting (bold, italic, font, size, colour)
- tables: add, read and modify rows, columns and cells
- sections and page setup: orientation, size and margins
- headers and footers
- styles: apply and define paragraph, character and table styles
- inline pictures sized in inches, centimetres or points
- comments (added in 1.2.0)
- core document properties (author, title, created and modified dates)
- hyperlinks: read a link's URL and fragment
- content it doesn't model is preserved when the document is saved

## Limitations

- Doesn't open the old binary .doc format from Word 2003 and earlier: it reads and writes Word 2007+ .docx files only[^1]
- Doesn't add floating pictures that text wraps around: python-docx only supports inline pictures[^2]

## Trust

Overall: 0.23 out of 1.
Signals: backing 0.20, extensibility 0.00.

- created by Steve Canny (scanny)

Warnings:

- GitHub activity not fetched yet

## Alternatives

- [Aspose.Words](https://talira.ai/catalog/aspose-words-4k0hy0ew.md): Create, edit, render and convert Word documents to multiple formats without using external software
- [rdocx](https://talira.ai/catalog/rdocx-w47ztd3z.md): Native DOCX creation, editing, comparison, layout, and rendering
- [docx2python](https://talira.ai/catalog/docx2python-tdeqb4ak.md): Extract docx headers, footers, text, footnotes, endnotes, properties, comments and images
- [docx4j](https://talira.ai/catalog/docx4j-mcywg4m2.md): JAXB-based Java library for Word docx, Powerpoint pptx, and Excel xlsx files
- [jubarte](https://talira.ai/catalog/jubarte-7tqbz11s.md): Word-faithful DOCX redlines and rendering, without Word

## Sources

[^1]: https://python-docx.readthedocs.io/en/latest/user/documents.html (checked 20 Nov 2026)
[^2]: https://python-docx.readthedocs.io/en/latest/user/shapes.html (checked 20 Nov 2026)
[^3]: https://github.com/python-openxml/python-docx/blob/master/LICENSE (checked 20 Nov 2026)
[^4]: https://pypi.org/project/python-docx/ (checked 20 Nov 2026)
[^5]: https://github.com/python-openxml/python-docx (checked 20 Nov 2026)
