Word to Markdown: converting a manuscript cleanly

Pandoc converts a .docx to Markdown in one command and gets the structure right about 90 percent of the time. The remaining 10 percent is the part that matters: direct formatting that was never a real heading, smart quotes, tracked changes, embedded images and Word's own list numbering. Budget an hour of cleanup, once, and you never do it again.

Almost every manuscript that ends up in Markdown started somewhere else, and that somewhere is usually Word. The conversion itself is easy. What is not obvious is that a Word file is not really a document — it is a document plus a long history of every formatting decision anyone ever made in it, including the ones they made by accident.

The one command

Pandoc is the tool. It reads the real .docx XML rather than guessing at a copy-paste, which is why it is the only route worth taking:

# Basic conversion
pandoc manuscript.docx -o manuscript.md

# Better: extract images, and use ATX headings (#) rather than underlines
pandoc manuscript.docx -o manuscript.md \
  --extract-media=./images \
  --markdown-headings=atx \
  --wrap=none

Those three flags are worth knowing. --extract-media pulls the embedded images out into a folder and rewrites the links — without it, images either vanish or arrive as unreadable base64. --markdown-headings=atx gives you ## Chapter instead of an underline of equals signs, which is what every other tool expects. --wrap=none puts each paragraph on one long line rather than hard-wrapping at 80 characters, which makes later editing far less painful.

Why the headings come out wrong

This is the big one, and it is not Pandoc's fault. In Word there are two ways to make text look like a chapter title. You can apply the Heading 1 style, or you can select the text and make it 18pt and bold. On screen these look identical. In the file they are completely different things: the first is structure, the second is decoration.

Pandoc can only convert structure. A chapter title that was manually bolded arrives in your Markdown as **Chapter One** — a bold paragraph, not a heading. Which means it will not appear in a table of contents, will not start a new page, and will not be styled as a chapter by anything downstream. Headings are the book's structure, and a book with no real headings has no structure to convert.

The fix is in Word, before you convert. Open the navigation pane (View → Navigation Pane). Any chapter that does not appear in it was never a heading. Select it, apply Heading 1, and repeat. On a 30-chapter manuscript this is twenty minutes and it makes the conversion work.

What else needs cleaning

What comes acrossWhat to do
Tracked changes and commentsAccept or reject all, delete all comments, before converting
Smart quotes and dashesKeep them — they are correct. Just be aware they are not ASCII
Manual line breaks mid-paragraphFind and remove. They become real breaks and wreck reflow
Double spaces after full stopsFind and replace with one. A typewriter convention
Tabs and manual indentsDelete. First-line indent is a type setting, not a character
Empty paragraphs for spacingDelete. Spacing is a margin, not a row of blank lines
Word's automatic list numbersCheck they arrived as 1. text rather than vanishing
Text boxes and floating imagesThese do not survive. Re-insert them as normal images
FootnotesPandoc converts them, but confirm your destination supports them

The empty-paragraph row is the one people resist, because those blank lines are load-bearing in Word. They are not load-bearing in a typeset book: the space between paragraphs is a property of the paragraph style, applied consistently everywhere, which is exactly why a typeset page looks even and a word-processed one does not.

A cleanup pass you can run

After conversion, these regular expressions catch most of what is left. Run them in any editor that supports find-and-replace with regex:

Find                    Replace     What it fixes
\ {2,}                  (space)     Multiple spaces
\n{3,}                  \n\n        Runs of blank lines
^\t+                    (nothing)    Leading tabs
\\$                     (nothing)    Stray hard line breaks
\*\*(.{1,60})\*\*$      ## $1        Bold-only lines that were headings

The last one is a helper, not a rule — review each match rather than replacing blindly, because a paragraph that legitimately ends in bold text will be caught too.

Going the other way, and why you might not need to

Pandoc converts back — pandoc manuscript.md -o manuscript.docx — which is worth knowing if an editor or a competition demands a Word file. Supply a reference document to control the styling:

pandoc manuscript.md -o manuscript.docx \
  --reference-doc=house-style.docx

But if the destination is a finished book rather than an editor's inbox, the round trip is unnecessary. The point of getting the manuscript into Markdown is that it is now plain text you own, readable in thirty years, versionable, and ready to be designed once and exported as many times as you like — a PDF and an EPUB from the same file, without either being converted from the other.

That is the honest argument for spending the hour. The conversion is a one-off cost; what you get is a manuscript that no longer depends on one application being able to open it. Google Docs versus Markdown makes the same case from the other direction, if you are still deciding.

Read next

Explainers · 5 min read

Google Docs, Word or Markdown: what to write a book in

Write in Google Docs if other people need to comment on the draft while you write it, in Word if an editor or publisher will hand you tracked changes, and in Markdown if the same manuscript has to become several finished formats without being reformatted each time. Most people who finish books use two of the three, in sequence.

Read it
Tools · 4 min read

Pandoc for books: what it is superb at, and where it stops

Pandoc is the best tool available for documents with citations, cross-references or mathematics, and for any book whose production is automated by a build. It stops being the pragmatic choice when your requirements are visual rather than structural, because every visual change is made by writing LaTeX or a template.

Read it
How-to · 6 min read

Headings in Markdown: turning a file into a book's structure

Use a single `#` for the book's title, `##` for every chapter and `###` for the sections inside them, and never skip a level. Those three marks are the only structure a Markdown file has, and everything downstream — the running hierarchy on the page, the printed contents, the EPUB's navigation — is read straight off them.

Read it

Write it in Markdown. Ship a book.

bukpress turns the file you are already writing into a typeset PDF and EPUB — your type, your covers, no watermark on any plan.

Start free — no card required