Skip to main content

python-docx-oss

A Python SDK for advanced creation and manipulation of Microsoft Word .docx files.

PyPI Python versions Code style: Ruff License: MIT

Overview

python-docx-oss is an independently evolving DOCX SDK built on the proven API foundation of python-docx. It keeps the familiar docx programming model while extending it for advanced OOXML and Open Packaging Convention (OPC) workflows.

Use it when an application needs more than basic paragraphs and tables: custom document metadata, application-owned XML, vector images, floating pictures, East Asian fonts, or low-level package and relationship access.

Features

Capability Support
Documents, paragraphs, runs, tables, styles, sections, headers, and footers
Custom document properties
Custom XML parts
SVG and EMF images
Inline and floating pictures
Independent ASCII, High ANSI, and East Asian font controls
Low-level OPC parts and relationships
File-path and in-memory stream processing

Installation

python -m pip install python-docx-oss

The distribution name is python-docx-oss, but the Python import namespace remains docx:

from docx import Document

[!WARNING] python-docx and python-docx-oss provide the same docx import namespace. Do not install both distributions in the same Python environment.

python-docx-oss currently supports Python 3.12, 3.13, and 3.14.

Quick Start

Create a document entirely in memory:

from io import BytesIO

from docx import Document

document = Document()
document.add_heading("Quarterly Report", level=1)
document.add_paragraph("Generated entirely in memory.")

output = BytesIO()
document.save(output)

docx_bytes = output.getvalue()

The same APIs also accept filesystem paths:

document = Document("input.docx")
document.add_paragraph("Appended by python-docx-oss.")
document.save("output.docx")

Advanced Capabilities

Custom properties

document = Document()
document.custom_properties["workflow_status"] = "approved"
document.custom_properties["revision"] = 3

Custom properties are visible in Microsoft Word and stored in /docProps/custom.xml. See Working with custom properties.

Custom XML

custom_xml = document.part.add_custom_xml_part(
    '<order xmlns="urn:example:orders" id="A-001"/>',
)
custom_xml.add_item("status", "ready")

See Working with Custom XML for lifecycle and compatibility considerations.

East Asian fonts

run = document.add_paragraph().add_run("English 与中文")
run.font.name = "Open Sans"
run.font.eastAsia = "Microsoft YaHei"

SVG and EMF streams can be passed to the standard picture APIs. Floating pictures are available through Document.add_float_picture() and Run.add_float_picture().

Compatibility and Scope

  • The project maintains broad compatibility with the public python-docx API while following its own versioning and product roadmap.
  • Compatibility does not extend to every private or internal python-docx API. Test those integrations before migrating production systems.
  • The SDK focuses exclusively on DOCX. It is not a general XLSX/PPTX Office suite.
  • It edits document structure but does not implement Word's page-layout rendering engine.
  • CLI, MCP, web, desktop, and Agent runtimes belong in separate packages that consume this SDK.

Documentation

Quality and Testing

The test suite combines unit and acceptance coverage with in-memory round-trip tests using documents created by Microsoft Word. The integration fixtures cover floating pictures, SVG fallback relationships, East Asian fonts, Custom XML parts, and core OPC package preservation.

For local development:

uv sync
uv run pytest
uv run ruff check .
uv run pyright

Project Status

The current focus is stabilizing the independent SDK baseline, its in-memory workflows, and its advanced OOXML capabilities before expanding document inspection, comparison, sanitization, composition, and validation APIs.

Credits

This project builds on the original work of python-docx creator Steve Canny and its contributors. python-docx-oss is maintained by Ethan St Lee and its contributors.

Why “OSS”?

In Brazilian jiu-jitsu, “oss” is a greeting and an expression of respect. It reflects the same spirit of discipline and collaboration behind this project.

License

python-docx-oss is released under the MIT License.

Support

If this project is useful to you, you can support its continued development through the donation page.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_docx_oss-0.1.1.tar.gz (8.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_docx_oss-0.1.1-py3-none-any.whl (266.3 kB view details)

Uploaded Python 3

File details

Details for the file python_docx_oss-0.1.1.tar.gz.

File metadata

  • Download URL: python_docx_oss-0.1.1.tar.gz
  • Upload date:
  • Size: 8.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.7

File hashes

Hashes for python_docx_oss-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4043fba29cc43aa7abc6b3821b08082126db77eb8972a757c025b2ddb057c450
MD5 a1aab9a185c92dfd294355a168dbc322
BLAKE2b-256 47d52405aac2b89974d072421e67a54bdeeff9227e09f0cf06ac3f8d1c1763ee

See more details on using hashes here.

File details

Details for the file python_docx_oss-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for python_docx_oss-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 086b707452370c952b0b95618de9058ae1433975e17edbfaadc5c0fdfb7995ac
MD5 18f483eb93cb45d42b873c5bb7c7a5b9
BLAKE2b-256 3fc3bb70f5030a0816b7b7f174cdb3199e17409ea913bb96d5d8815f8a247895

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 files

0.1.0

2 files

0.0.12

1 file

0.0.11

1 file

0.0.10

1 file

0.0.9

1 file

0.0.8

1 file

0.0.7

1 file

0.0.6

1 file

0.0.5

1 file

0.0.4

1 file

0.0.3

1 file

0.0.2

1 file

0.0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page