# Converting Word documents (DOCX) to Markdown with MarkItDown

> MarkItDown 0.1.9 on Word files: what survives (headings, lists, tables), what breaks (table headers, pipes, nested bullets, images) and how to fix it.

Source: https://markitdown.dev/formats/word/ · Updated 2026-11-15·Upstream source ↗

Word is where MarkItDown is strongest, because a DOCX file really does contain headings, lists and tables. We built one test file per feature, converted each with version 0.1.9 and judged the result against the Markdown it should have produced: of 35 Word features, 19 were kept, 13 changed and 3 lost (one more row is the legacy `.doc` case).

> **Short answer**
>
> Install the extra, convert, save with `-o`:
> 
> ```bash
> pip install "markitdown[pdf]"
> ```
> 
> ```bash
> markitdown report.docx -o report.md
> ```
> 
> (Use `docx` instead of `pdf` in the first command.) Headings, emphasis, lists, links and tables come through. Check **table header rows, cells that contain `|`, the document title, nested bullets and images**.

Tested with markitdown 0.1.9 · Python 3.13 · markitdown\[all\] 0.1.9 · Linux lab; the DOCX corpus also ran on Windows, macOS and Ubuntu runners (T03, T05) · LibreOffice 24.2, Pandoc 3.1 for building test files · 2026-11-15 · evidence: [office-features.csv](https://markitdown.dev/data/office-features.csv), [format-matrix.csv](https://markitdown.dev/data/format-matrix.csv), [docx-features.jsonl](https://markitdown.dev/evidence/T07/docx-features.jsonl)

## Feature by feature: kept, changed, lost

*Kept* means the Markdown matches what the feature should produce; *changed* means it survives but differently; *lost* means it is not in the output.

35 Word features, one test file each, markitdown 0.1.9
| Feature | Result | What came out | Note |
| --- | --- | --- | --- |
| Title and Subtitle styles | lost | `The Document Title↵↵A subtitle line↵↵# First section↵↵Body text.` | Title is a paragraph style, not a heading. missing: \['# The Document Title'\] |
| Heading levels 1 to 6 | kept | `# Heading level 1↵↵## Heading level 2↵↵### Heading level 3↵↵#### Heading level 4↵↵##### Heading level 5↵↵###### Heading level 6` |  |
| Bold, italic, underline, strike | kept | `**bold** *italic* <u>underlined</u> ~~struck~~ x2 H2` | Underline and strike come out as HTML-style or Markdown markers; see the excerpt. |
| Underline, strike, superscript, subscript | changed | `**bold** *italic* <u>underlined</u> ~~struck~~ x2 H2` | Underline becomes <u>…</u>, strike becomes ~~…~~; check superscript and subscript in the excerpt: kept as plain digits |
| Hyperlink | kept | `See [the example page](https://example.org/page) for details.` |  |
| Nested bullets by paragraph style | changed | `* Top one↵* Second level↵* Third level↵* Top two` | Compare the indentation of the three levels. missing: \[' \* Second level', ' \* Third level'\] |
| Numbered list by paragraph style | changed | `1. First↵2. Second↵3. Nested number↵4. Third` | missing: \['3. Third'\] |
| Nested bullets with list levels | kept | `* Top one↵ + Second level↵ - Third level↵* Top two` | Real list levels survive; the bullet character alternates (\* + -). |
| Numbered list with list levels | kept | `1. First↵ 1. Nested↵2. Second↵3. Third` |  |
| Table with a marked header row | kept | `| Station | Rainfall | Notes |↵| --- | --- | --- |↵| Alpha | 412.5 | ok |↵| Bravo | 388.0 | low |` | Check whether the first line of the table is the header or an empty row. |
| Table without a header-row flag | changed | `| | | |↵| --- | --- | --- |↵| Station | Rainfall | Notes |↵| Alpha | 412.5 | ok |↵| Bravo | 388.0 | low |` | The flag set in Word (Table Design, Header Row, Repeat as header) decides whether the header is real. the table starts with an empty header row; the real first row is the second line. |
| Title style mapped to a heading | kept | `# The Document Title↵↵A subtitle line↵↵# First section↵↵Body text.` | style\_map is a constructor argument. |
| Subtitle style mapped to a second-level heading | kept | `# The Document Title↵↵## A subtitle line↵↵# First section↵↵Body text.` |  |
| Merged cells | changed | `| | | |↵| --- | --- | --- |↵| Merged title across three columns | | |↵| A | B | C |↵| 1 | 2 | 3 |` | the table starts with an empty header row; the real first row is the second line. |
| A pipe character inside a cell | changed | `| | |↵| --- | --- |↵| Key | Value |↵| state | OK | stable |` | An unescaped | adds a column. the pipe is not escaped, so the row gets an extra cell |
| Pipe workaround: escape the pipe in the file first | changed | `| | |↵| --- | --- |↵| Key | Value |↵| state | OK \| stable |` | Edits the DOCX XML (script in the page); the document shown to the reader is unchanged. the table starts with an empty header row; the real first row is the second line. |
| Multi-paragraph cell | changed | `| | |↵| --- | --- |↵| Name | Details |↵| Alpha | first paragraph second paragraph |` | the table starts with an empty header row; the real first row is the second line. |
| Nested table | changed | `| | | | | | |↵| --- | --- | --- | --- | --- | --- |↵| outer left | | | | | --- | --- | | in1 | in2 | | in3 | in4 | |` | the table starts with an empty header row; the real first row is the second line. |
| Wide table (12 columns) | changed | `| | | | | | | | | | | | |↵| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |↵| H1 | H2 | H3 | H4 | H5 | H6 | H7 | H` | the table starts with an empty header row; the real first row is the second line. |
| Embedded picture, no alt text | kept | `![](data:image/png;base64...)↵↵After` | By default the image data is cut off; see keep\_data\_uris. |
| Embedded picture with alt text | kept | `![A bar chart of quarterly revenue](data:image/png;base64...)` | The alt text is used as the Markdown alt text. |
| keep\_data\_uris on a picture | kept | `Before↵↵![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAFoCAIAAABIUN0GAAAgmUlEQVR4nO3dd1yV5f/H8QsPIgii4gAHigriwJl7pObELe7ZMCvN3KY2rF+WWZm5Mssc` | Output grows from 44 to 11246 characters. |
| Page break | kept | `Page one text↵↵Page two text` |  |
| Header and footer text | lost | `Page one text↵↵Page two text` | Headers and footers are not read. missing: \['Running header text', 'Running footer text'\] |
| Comments | lost | `Text with a comment attached.` | Comments are not part of the main document text. missing: \['This is the reviewer comment.'\] |
| Tracked changes (insertion and deletion) | kept | `Kept text inserted words` | Deleted text should not appear. |
| Custom styles without a mapping | kept | `print('hello')↵↵A key phrase inside text.` | Unmapped custom styles come out as ordinary text. |
| Custom paragraph style mapped to code | kept | `print('hello')↵```↵↵A key phrase inside text.` |  |
| Custom character style mapped to emphasis | kept | `A *key phrase* inside text.` |  |
| Footnotes | changed | `A sentence with a note.[[1]](#footnote-20)↵↵1. The footnote text itself. [↑](#footnote-ref-20)` | Footnote text is in a separate part of the file. the reference becomes a link to #footnote-N and the note text is a numbered list at the end |
| Table of contents | kept | `# One↵↵text↵↵# Two↵↵text↵↵## Two point one↵↵text` |  |
| Equation | kept | `Inline $x^{2}+y^{2}=z^{2}$ and display:↵↵$$\frac{a}{b}=c$$` | Equations are converted to LaTeX when markitdown can read the Office Math. |
| Block quote and code block | changed | `A quoted line.↵↵code line one↵code line two` | Code blocks have no fence; check the excerpt. missing: \['> A quoted line.'\] |
| Right-to-left text | kept | `مرحبا بالعالم עברית` |  |
| Document written by LibreOffice | changed | `# LO Title↵↵* one↵ + two↵ - three↵↵1. a↵2. b↵↵| | |↵| --- | --- |↵| H | V |↵| 1 | 2 |` | The 'w:ilvl' KeyError reported upstream concerns non-Word writers; we record what this file does. the table starts with an empty header row; the real first row is the second line. |

*35 Word features, one test file each, markitdown 0.1.9 Source: Test T07 · Linux lab · 2026-11-15 · office-features.csv · Download CSV*

## See it on a document

The synthetic report from the quickstart, with each part of the output tied to the region it came from:

**Proof comparison:** 5 headings → 4 kept, 1 changed · 1 paragraph → 1 kept · 2 lists → 2 kept · 1 table → 1 kept

````markdown
Pilot Report: Field Station Alpha
 
# 1. Summary
 
This report covers **three sites** during *spring 2026* <u>with underlined</u> ~~and struck text.~~
 
## 1.1 Key findings
 
* Rainfall rose 12% year on year
* Sensor uptime reached 99.2%
* Two stations need new batteries
* Nested item under batteries
 
## 1.2 Next steps
 
1. Order batteries
2. Recalibrate sensors
3. Publish dataset
 
# 2. Measurements
 
|  |  |  |  |
| --- | --- | --- | --- |
| Station | Rainfall (mm) | Uptime | Notes |
| Alpha | 412.5 | 99.2% | Battery low |
| Bravo | 388.0 | 97.8% | OK | stable |
| Charlie | 451.3 | 99.9% | New sensor |
 
## 2.1 Chart
 
![](data:image/png;base64...)
 
Figure 1: Quarterly revenue chart.
 
### 3. Deep heading level three
 
Contact: hello@example.org — see https://example.org/data for the dataset. Unicode check: café, naïve, 東京, Ω, emoji 🙂.
````

- ~ changed heading becomes plain text: Pilot Report: Field Station Alpha
- ✓ kept heading: 1. Summary
- ✓ kept paragraph: This report covers three sites during sp
- ✓ kept heading: 1.1 Key findings
- ✓ kept list: Rainfall rose 12% year on year
- ✓ kept heading: 1.2 Next steps
- ✓ kept list: Order batteries
- ✓ kept heading: 2. Measurements
- ✓ kept table: Station

On our 15-file Word corpus (real files from other tools plus synthetic ones) the grades were 4 A, 7 B, 2 C and 2 X, the two X being a corrupt file and a zero-byte file ([grading method](https://markitdown.dev/formats/)).

## How MarkItDown reads a Word file

The document is turned into HTML by the Mammoth library using Word *styles*, and the HTML is turned into Markdown. So **what matters is the style applied in Word, not how the text looks**: a line made big and bold by hand is a paragraph; a line in the Heading 2 style is a `##`.

## The document title is not a heading

Paragraphs in the Title and Subtitle styles come out as plain paragraphs:

````markdown
The Document Title

A subtitle line

# First section

Body text.
````

*docx-W01.md · 64 bytes*

Mapping the styles fixes it (the full mechanism is [below](#style-map)):

````markdown
# The Document Title

## A subtitle line

# First section

Body text.
````

*docx-W01c.md · 69 bytes*

## Tables: the empty header row and the pipe problem

### The header row is empty

A table whose first row is not flagged as a header row in Word gets an empty header line, with the real header as the first data row:

````markdown
|  |  |  |
| --- | --- | --- |
| Station | Rainfall | Notes |
| Alpha | 412.5 | ok |
| Bravo | 388.0 | low |
````

*docx-W07b.md · 108 bytes*

The same table with the flag set (Table Design, Header Row, then Repeat as header row) comes out right:

````markdown
| Station | Rainfall | Notes |
| --- | --- | --- |
| Alpha | 412.5 | ok |
| Bravo | 388.0 | low |
````

*docx-W07.md · 97 bytes*

Merged cells, multi-paragraph cells, nested tables and a 12-column table all produced a table with the empty header row; the merged title appeared once in its first cell and the other cells were empty (sample files: [no header flag](https://markitdown.dev/samples/docx-table-no-header.docx), [header flag](https://markitdown.dev/samples/docx-table-header.docx)).

### A `|` inside a cell breaks the row

Unlike the CSV converter, Word cell text is not escaped, so `OK | stable` adds a column:

````markdown
|  |  |
| --- | --- |
| Key | Value |
| state | OK | stable |
````

*docx-W09.md · 61 bytes*

The workaround we tested is to escape the pipe in the file before converting; it produced `OK \| stable`:

````markdown
|  |  |
| --- | --- |
| Key | Value |
| state | OK \| stable |
````

*docx-W09b.md · 62 bytes*

The recipe is in `lab/scripts/t07_docx.py` (`escape_pipes`).

## Lists: when nesting survives

It depends on how the list was made. Real multi-level lists (what Word produces) keep their nesting, with the bullet character alternating `*`, `+`, `-`:

````markdown
* Top one
  + Second level
    - Third level
* Top two
````

*docx-W05b.md · 54 bytes*

Lists built by applying a different paragraph style to each line (List Bullet 2, List Bullet 3) are flattened to one level:

````markdown
* Top one
* Second level
* Third level
* Top two
````

*docx-W05.md · 48 bytes*

Numbered lists with real levels come out as `1.` `2.` `3.` with the nested item indented; the style-based version numbers the nested item as a fourth top-level item. [Sample with list levels](https://markitdown.dev/samples/docx-nested-bullets.docx), [sample with styles](https://markitdown.dev/samples/docx-bullets.docx).

## Images inside Word files

Each embedded picture becomes `![](data:image/png;base64...)`: the data is cut off, and the alt text, when the picture has one, is kept:

````markdown
![A bar chart of quarterly revenue](data:image/png;base64...)
````

*docx-W14.md · 61 bytes*

With `keep_data_uris=True` the full base64 stays (our file's output grew from 44 to 11,246 characters). Extracting pictures to files and descriptions: [image page](https://markitdown.dev/formats/images/).

## Customising with `style_map`

`style_map` is a Mammoth style-mapping rule list passed to the constructor, so it is Python only: there is no command-line option for it ([CLI reference](https://markitdown.dev/cli/)). Three tested mappings, applied together:

```python
from markitdown import MarkItDown

# Title and Subtitle paragraph styles, a custom paragraph style and a custom character style
rules = "\n".join([
    "p[style-name='Title'] => h1:fresh",
    "p[style-name='Subtitle'] => h2:fresh",
    "p[style-name='CodeBlock'] => pre:fresh",
    "r[style-name='Highlight Phrase'] => em",
])
md = MarkItDown(style_map=rules)
print(md.convert("samples/docx-title-subtitle.docx").markdown.split("\n\n")[0:2])
print(md.convert("samples/docx-custom-styles.docx").markdown)
```

Output · markitdown 0.1.9 · Python 3.13.18 · 2026-11-15

````
['# The Document Title', '## A subtitle line']
```
print('hello')
```

A *key phrase* inside text.
````

[captured result](https://markitdown.dev/evidence/snippets/api-style-map-custom/result.json)

Without a mapping, custom styles come out as ordinary text:

````markdown
print('hello')

A key phrase inside text.
````

*docx-W28.md · 41 bytes*

A mapping cannot infer headings from appearance and does not affect tables. We did not test how rules embedded in the document interact with yours. [Sample with the custom styles](https://markitdown.dev/samples/docx-custom-styles.docx).

## Footnotes, comments, tracked changes, headers and footers

-   **Footnotes** survive as text, but the reference becomes a link to `#footnote-N` and the note is a numbered list at the end.
-   **Comments** are lost: the comment text is not in the output.
-   **Tracked changes:** inserted text is kept and deleted text does not appear, which silently changes the meaning if you needed to see the deletions.
-   **Headers and footers** are lost.

````markdown
A sentence with a note.[[1]](#footnote-20)

1. The footnote text itself. [↑](#footnote-ref-20)
````

*docx-W20.md · 96 bytes*

## Equations

Word equations come out as LaTeX between `$` for inline and `$$` for display:

````markdown
Inline $x^{2}+y^{2}=z^{2}$ and display:

$$\frac{a}{b}=c$$
````

*docx-W22.md · 58 bytes*

## Legacy `.doc` files

A `.doc` file raises `UnsupportedFormatException`. The route we tested: convert it to `.docx` with LibreOffice in headless mode, then MarkItDown. The result was identical to converting the original DOCX:

```bash
soffice --headless --convert-to docx report.doc
```

Several files: [batch conversion](https://markitdown.dev/batch/). `.rtf` and `.odt`: [the formats page](https://markitdown.dev/formats/).

## Errors specific to Word files

Reproduced by us · fixed in 0.1.9

### DocxConverter threw IndexError with message: pop from empty list

A field-end mark with no matching field-begin mark in the document made the DOCX reader (mammoth before 1.12.2) pop from an empty list.

Affected: 0.1.6 and 0.1.8 (tested; mammoth 1.11) · last reproduced 2026-11-15 · [Upstream report](https://github.com/microsoft/markitdown/issues/2646)

Reported, not reproduced by us

### DocxConverter threw KeyError with message: 'w:ilvl'

Reported for DOCX files written by tools other than Word; the underlying DOCX reader (mammoth) fails on a numbering definition it does not expect.

Affected: reported on 0.1.x · [Upstream report](https://github.com/microsoft/markitdown/issues/1282)

A file written by LibreOffice, with nested lists and a table, converted without an error in our test (row W25); we could not produce the `w:ilvl` error ourselves.

## Files from Google Docs, LibreOffice and Pages

LibreOffice files convert, with nested lists intact and the same empty table header row. We did not have Google Docs or Pages exports to test, so we make no claim about them.

## Version notes for Word

-   since 0.1.2 Equations in DOCX.
-   since 0.1.3 Fixes for alt text with line breaks and for linked images.
-   since 0.1.4 Newer Mammoth (1.11).
-   since 0.1.9 Mammoth 1.12.2 or newer is required.

## Mammoth or Pandoc?

We built the test files for this page with Pandoc but did not compare its conversion with MarkItDown's. MarkItDown is one tool for many formats and returns text meant for language models: [the comparison](https://markitdown.dev/compare/pandoc/).

## Related

- [Supported formats](https://markitdown.dev/formats/): How every file type converts, graded.
- [Excel (XLSX, XLS)](https://markitdown.dev/formats/excel/): Excel: the same kind of feature table.
- [Images](https://markitdown.dev/formats/images/): Keeping, extracting and describing images.
- [Python API guide](https://markitdown.dev/python-api/): The Python API, including style_map.
- [MissingDependencyException, FileConversionException, UnsupportedFormatException](https://markitdown.dev/errors/missing-dependency/): Errors from missing extras and unsupported types.

---
Independent guide to the open-source MarkItDown library. Not affiliated with or endorsed by Microsoft. Official source: https://github.com/microsoft/markitdown
