whatisgithub

What is python-docx?

python-openxml/python-docx — explained in plain English

Analysis updated 2026-06-26

5,575PythonAudience · developerComplexity · 2/5Setup · easy

In one sentence

python-docx is a Python library for creating, reading, and editing Microsoft Word .docx files entirely from code. Add paragraphs, headings, tables, and images without opening Word.

Mindmap

mindmap
  root((repo))
    What it does
      Read Word files
      Create Word files
      Edit Word files
    Supported elements
      Paragraphs
      Headings
      Tables
      Images
    Use cases
      Report generation
      Template filling
      Text extraction
    Setup
      pip install
      No extra dependencies
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Generate Word reports automatically from a Python script without opening Microsoft Word

USE CASE 2

Fill in a document template by replacing placeholder text with real data from a database or API

USE CASE 3

Extract all text from .docx files for search indexing or further processing

USE CASE 4

Add formatted tables, headings, and images to a Word document from code

What is it built with?

Python

How does it compare?

python-openxml/python-docxhuggingface/parler-ttslanmaster53/recon-ng
Stars5,5755,5765,577
LanguagePythonPythonPython
Setup difficultyeasymoderatemoderate
Complexity2/53/53/5
Audiencedeveloperdeveloperops devops

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min
License terms are not stated in the explanation, though the project is open-source.

So what is it?

python-docx is a Python library for reading, creating, and modifying Microsoft Word files in the .docx format. Word files from 2007 onward use this format, so the library covers any modern Word document. The library lets you open an existing document and read its contents, add new paragraphs, headings, tables, images, and other elements, then save the result as a new or updated .docx file. The README shows a minimal example: creating a blank document, adding a paragraph, saving it, then reopening it and reading the paragraph back out. More detailed documentation is available on the project's ReadTheDocs site. Installation is a single command via pip, the standard Python package manager. The library is useful for any situation where you want to generate Word documents from code rather than opening Word manually. Common use cases include generating reports, filling in document templates, or extracting text from Word files for further processing. The README itself is brief and points to external documentation for full usage details.

Copy-paste prompts

Prompt 1
Using python-docx, write a script that creates a Word document with a title, three body paragraphs, and a 3-column table
Prompt 2
How do I open an existing .docx file with python-docx and replace every occurrence of a specific word with new text?
Prompt 3
Write Python code using python-docx to insert an image into a Word document and add a caption below it
Prompt 4
How do I extract all the paragraph text from a .docx file using python-docx and save it to a plain .txt file?
Prompt 5
Generate a Word invoice from a Python dictionary of customer name, line items, and totals using python-docx

Frequently asked questions

What is python-docx?

python-docx is a Python library for creating, reading, and editing Microsoft Word .docx files entirely from code. Add paragraphs, headings, tables, and images without opening Word.

What language is python-docx written in?

Mainly Python. The stack also includes Python.

What license does python-docx use?

License terms are not stated in the explanation, though the project is open-source.

How hard is python-docx to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is python-docx for?

Mainly developer.

Open on GitHub → Ask about another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.