Skip to main content

doc2docx

doc2docx is a pure-Python converter from Microsoft Word 97–2003 binary .doc files to modern .docx files. The conversion engine follows the published Microsoft Office binary-format specifications and does not invoke Microsoft Word, LibreOffice, COM, Java, or another conversion executable.

The project is usable for a growing set of real documents, but it is not yet a complete implementation of every legacy Word feature. Unsupported or lossy content is reported explicitly instead of being silently presented as a fully faithful conversion.

Highlights

  • Reads CFB/OLE Word documents with deterministic, bounded parsers.
  • Opens XOR-obfuscated, classic RC4, and RC4 CryptoAPI password-protected documents when a password is supplied.
  • Preserves text, common character and paragraph formatting, fonts, styles, native numbered and bulleted lists, tables, page layout, section page and line numbering, paragraph text frames, floating table positioning, headers, and footers.
  • Converts footnotes and endnotes—including custom separators, placement, and numbering controls—plus comments, named bookmarks, safe document-local reference fields, common date/metadata/page/statistic fields, and positioned textboxes to native WordprocessingML structures.
  • Preserves core document metadata such as title, author, subject, keywords, revision, and creation/modification dates.
  • Restores inline and floating PNG, JPEG, BMP/DIB, TIFF, EMF, and WMF pictures in the main document and header/footer stories, including rotation, flips, tight/through wrap polygons, and common floating preset shapes such as polygons, stars, arrows, lines, and plaques.
  • Preserves confirmed embedded OLE ObjectPool storages as native DOCX embedded objects, and retains Macintosh PICT payloads for consumers that can render them.
  • Produces a structured diagnostic report for unsupported, repaired, or approximated source features.
  • Writes deterministic OPC packages using only the Python standard library at runtime.

Installation

python -m pip install msdoc2docx

Python 3.10 or newer is required.

Command line

Convert beside the input file:

doc2docx input.doc

Choose the output path and save a JSON report:

doc2docx input.doc -o output.docx --report report.json

For a password-protected document, prefer a UTF-8 password file so the secret does not appear in the process command line:

doc2docx protected.doc --password-file password.txt

Inspect a source file without converting it:

doc2docx inspect input.doc --json

Convert a directory while preserving its relative layout and write one JSON summary for successful and failed files:

doc2docx batch input-directory -o output-directory --recursive --report batch.json

Python API

from doc2docx import convert

result = convert("input.doc", "output.docx", password="secret")
print(result.report.to_dict())

The source document is opened read-only. The destination and JSON reports are written through temporary files and atomically replaced after validation or serialization; the converter will not overwrite the input file. Report paths are also checked against source and output paths, including every input and destination in batch mode.

Current limitations

Grouped/custom OfficeArt geometry and advanced drawing effects remain incomplete. Unsupported geometry with a reliable wrap contour is retained as an explicitly diagnosed contour approximation; geometry without such evidence is deferred. Linked or unanchored OLE storages are not activated or guessed; only confirmed embedded-object anchors are packaged. Macintosh PICT images are retained as original media, although rendering them depends on support in the DOCX consumer. The legacy macro story has no safe WordprocessingML equivalent and is deliberately omitted. Fields that can execute actions or access external content are kept as cached text. Some legacy layout behavior can only be approximated in WordprocessingML and is called out in the conversion report.

See CHANGELOG.md for milestone and release details.

Development

Run the standard-library test suite from a source checkout:

PYTHONPATH=src python -m unittest discover -v

Build distributable artifacts with:

python -m build

Real-document regression tests may use LibreOffice to create or render test artifacts, but LibreOffice is not used by the converter itself.

Specifications

Download files

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

Source Distribution

msdoc2docx-0.36.5.tar.gz (217.9 kB view details)

Uploaded Source

Built Distribution

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

msdoc2docx-0.36.5-py3-none-any.whl (170.8 kB view details)

Uploaded Python 3

File details

Details for the file msdoc2docx-0.36.5.tar.gz.

File metadata

  • Download URL: msdoc2docx-0.36.5.tar.gz
  • Upload date:
  • Size: 217.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for msdoc2docx-0.36.5.tar.gz
Algorithm Hash digest
SHA256 0de47dbe150a6617788e6405e1bed424f207c7ce054de48da2398696c2c44378
MD5 38cc8250a095cc3a8e80d2852bdb9b56
BLAKE2b-256 fcdfec7790a74013d0278c20d19c6aba4195b4793c9f0747cf6c7b37b68a921e

See more details on using hashes here.

File details

Details for the file msdoc2docx-0.36.5-py3-none-any.whl.

File metadata

  • Download URL: msdoc2docx-0.36.5-py3-none-any.whl
  • Upload date:
  • Size: 170.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for msdoc2docx-0.36.5-py3-none-any.whl
Algorithm Hash digest
SHA256 956b0d3146ad9deba6b9d82a78c910a32958eafcbdd486c15bb0bd9ebc49e6f1
MD5 b8171902804fb62a40717aa6f577430a
BLAKE2b-256 15e9d8b754f6b9acbdfb8a93d50f30a539d5e57778057b8506b5569bfd512923

See more details on using hashes here.

Release history Release notifications | RSS feed

0.36.6

2 files

This release

0.36.5 This release

2 files

0.36.4

2 files

0.36.2

2 files

0.36.1

2 files

0.36.0

2 files

0.35.0

2 files

0.34.0

2 files

0.33.0

2 files

0.32.0

2 files

0.31.0

2 files

0.30.0

2 files

0.29.0

2 files

0.28.0

2 files

0.27.0

2 files

0.26.0

2 files

0.25.0

2 files

0.24.0

2 files

0.23.0

2 files

0.22.0

2 files

0.21.0

2 files

0.7.0

2 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