Markdown to Word

Published Updated

Turn Markdown into a DOCX built from the parsed document: headings, nested lists, quotes, code blocks, bold, italic, strikethrough and working links. Tables become pipe-separated lines of text, images become [image: alt] notes and raw HTML shows as literal tags.

What lands in the document

A sample with every common element went through the page in Google Chrome 156. The package was read back to check it.

MarkdownIn Word
# Title to ###### TitleHeading 1 to Heading 6 styles
**bold**, *italic*, ~~strike~~Bold, italic and strikethrough runs
code and fenced blockConsolas text; a block is one Code Block paragraph with line breaks
[link](https://example.com)A real hyperlink with an external relationship
- and 1. lists, nestedBullets and decimal numbering up to 9 levels
> quoteQuote style
---A paragraph with a bottom border

Inside the file

A .docx is a zip of XML parts. Microsoft's WordprocessingML overview names word/document.xml as the main document part. The page writes that part plus styles.xml, numbering.xml, two relationship files and a content-types file. All six XML parts parse as well-formed in the files measured below.

Lists, tables, images and footnotes in the .docx, measured

Generated Markdown went through the converter in Node.js 22.23.1, Google Chrome 157, Firefox 155 and Playwright's WebKit build (not the Safari app). The files were opened with Python's zipfile and an XML parser. For all 19 inputs every XML part was the same in the four runtimes. Each row below is what one input became.

MarkdownIn the .docx
3. third, 4. fourth, 5. fifthThree numbered paragraphs under one numbering entry that starts at 3
Two numbered lists with a paragraph between themTwo numbering entries, each with a start value of 1 on every level, so the second list begins again at 1
A numbered list nested in a bullet item, and a bullet list nested in a numbered itemThe nested list gets its own entry of its own kind (decimal under the bullet, bullet under the number) on level 2
A table whose cells hold **b** and a code spanOne paragraph per row, cells joined by | , bold and Consolas runs kept, header row bold; the colons in the delimiter row set no alignment
![alt text](pic.png), ![](nopic.png), a linked imageItalic [image: alt text]; nothing for an empty alt text; a hyperlink around the italic note for the linked image
A footnote reference and its definitionTwo plain text lines: the reference and the definition, brackets included
A block quote holding a list itemQuote-style paragraphs; the item keeps its bullet
A vertical tab, a form feed and U+0001 inside a sentenceRemoved from the text; tabs and line breaks stay; all six parts parse as XML

CommonMark takes the start number of an ordered list from its first item, and the file carries it as a start value. The GitHub Flavored Markdown table syntax uses colons in the delimiter row for left, right or center alignment; the converter does not use them.

The same Markdown, three browsers, one set of parts

The zip step uses each browser's own deflate, so the .docx size differs while the XML does not. The 400-section file has a 433,689 byte document.xml and took 21 ms to build in Chrome 157, 77 ms in Firefox 155 and 26 ms in the WebKit build (41 ms in Node.js). Sizes in bytes:

Markdown inputNode.jsChrome 157Firefox 155WebKit build
Headings 1 to 6 and two setext headings2,6512,6512,6462,644
A table with alignment colons2,6672,6672,6612,661
A code span, a fenced block and an indented block2,7052,7052,6992,694
400 sections with a list and a link each17,61117,61117,54121,188

The page itself names the download after the file or, for pasted text, document.docx, with the Word media type; pasted text with a three-item numbered list and one paragraph gave 2,695, 2,688 and 2,685 bytes in the three browsers.

Making the document

  1. Step 1

    Paste Markdown or add a file

    A .md or .txt file fills the editor, and the Preview tab shows how the text reads as a web page. The download is named after the file, or document.docx.

  2. Step 2

    Check the Preview tab

    It is drawn as HTML, with real table borders. The Word file is built separately, so tables look different there.

  3. Step 3

    Download the .docx

    The styles written are Heading 1 to 6, Quote, Code Block and List Paragraph. Open the file once in your word processor to check its look.

Known gaps

  • Tables are plain lines with pipes, not Word tables.
  • Images are replaced by a bracketed alt-text note.
  • Task list checkboxes and HTML tags are not interpreted.
  • For a web version of the same text, Markdown to HTML shows real tables, and Markdown to PDF makes a page-ready file.

Markdown to Word questions

Why is my table not a table in Word?

The converter writes each row as one line of text with cells joined by a pipe, and the header row in bold. In the test, h1 and h2 became the line h1 | h2. If you need a real table, insert one in Word and paste the cells.

Where did my images go?

They are not embedded. An image becomes an italic note in square brackets with its alt text, such as [image: alt text]. Nothing is fetched from the web, and an image without alt text leaves nothing.

What happens to task list boxes?

The checkbox is lost. The item - [x] done came out as a plain bulleted line reading done.

Why do my HTML tags appear in the document?

Raw HTML is not interpreted. A div block or a bold tag inside a sentence is written as literal characters, brackets included. Use Markdown bold instead.

Does it keep nested lists and numbering?

Yes. A bullet list with a nested item produced two list levels, and each list gets its own numbering entry in the file. A numbered list that starts at 3 is written with a start value of 3, and a second numbered list starts again at 1.

Is the text uploaded to be converted?

No. The marked parser and the file writer both run in the page, and the download is built in memory.

Does a numbered list that starts at 3 keep its numbers?

Yes. The list 3. third, 4. fourth, 5. fifth is written as three numbered paragraphs under one numbering entry with a start value of 3. A later numbered list gets its own entry that starts at 1.

Is bold text inside a table cell kept?

Yes. Bold, italic, code spans and links inside cells keep their formatting, and the cells of a row are joined with a pipe. The alignment colons in the delimiter row are not used.

Why is the .docx a different size in each browser?

The XML parts are the same, but the browser's own deflate compresses them differently. A 400-section test file came to 17,611 bytes in Chrome 157, 17,541 in Firefox 155 and 21,188 in the WebKit build.

What happens to characters such as a vertical tab or form feed?

They are removed, because XML cannot hold most control characters and the document would not parse. Tabs and line breaks stay.

Related Tools