Home/Guides/Converter
๐Ÿ“Converter

Extracting Text from Word Documents: What a .docx Really Contains

A .docx is a ZIP of XML parts. Why naive extraction splits words, what plain text loses that HTML keeps, and which content every extractor misses.

7 min read

When you need the words and nothing else

A folder of Word documents has to become something a program can read: rows in a database, input to a search index, chunks for a language model, or plain text for a diff. Opening each one and copying by hand does not scale, and opening a .docx in a text editor shows binary noise. This guide explains what is inside the file, what you lose when you extract text, and when plain text is the right target versus HTML.

A .docx is a ZIP archive

Since Word 2007, a .docx has been an Open Packaging Convention container: a ZIP file holding XML parts. Rename one to .zip, open it, and the structure is plain to see.

Path inside the archiveWhat it holds
word/document.xmlThe body text and its formatting runs โ€” the part everyone wants
word/styles.xmlStyle definitions: Heading 1, Normal, and so on
word/media/Every embedded image, as its original file
word/footnotes.xml, endnotes.xmlNotes, kept out of the main body
word/header1.xml, footer1.xmlRunning headers and footers, one part per section
docProps/core.xmlAuthor, title, created and modified timestamps
word/comments.xmlReview comments, if any survive in the file

Two consequences matter. Text extraction is an XML problem, not a reverse-engineering problem, which is why it can run reliably in a browser. And a .doc from Word 97โ€“2003 is a completely different, genuinely binary format โ€” those must be converted to .docx in Word or LibreOffice first.

Why extraction is not just stripping tags

Word splits a sentence into runs whenever formatting changes. A line reading Total: 42 unitswhere only the number is bold becomes three separate runs in the XML. A naive extractor that concatenates text nodes without understanding paragraph boundaries produces one of two classic failures: everything run together into a single line, or a line break inserted in the middle of every formatted phrase.

Spell-check and tracked-change markers make it worse โ€” Word sometimes splits a single word across runs mid-spelling, so careless extraction yields doc ument. A correct extractor walks paragraphs, joins runs inside each one, and emits a break only at real paragraph and table-cell boundaries. This is what separates a usable result from one you spend an afternoon cleaning.

Plain text or HTML?

The two tools answer different downstream needs, and picking the wrong one means either cleaning markup you did not want or trying to reconstruct structure you already had.

  • Word to Text gives .txt: paragraphs, no markup. Right for full-text search indexing, word counts, diffing two revisions, feeding a model, or any pipeline where formatting is noise. Headings become ordinary lines, so document structure is gone.
  • Word to HTML keeps semantic structure โ€” headings as h1 to h6, lists as ul and ol, tables as real tables, bold and italic preserved. Right for publishing to a CMS, converting to Markdown afterwards, or any case where knowing what is a heading matters. Note this is semantic HTML, not a pixel-faithful reproduction of the Word layout.

A useful rule: if the next step is a machine deciding what the document is about, take text. If the next step involves a human reading it or a system that cares about hierarchy, take HTML.

What extraction always loses

  • Page layout. A DOCX has no fixed pages โ€” Word repaginates on the fly according to the printer driver. There are no page numbers to extract because they do not exist in the file.
  • Headers, footers and footnotes live in separate XML parts and are normally excluded from body extraction. If a footnote carries the citation you need, check for it explicitly.
  • Images are separate files in the archive. Text extraction skips them; to retrieve them, treat the document as a ZIP and pull word/media/.
  • Text boxes and SmartArt sit in drawing parts outside the main paragraph flow and are frequently missed by every extractor, including commercial ones.
  • Tracked changes. Depending on the extractor, deleted text may or may not appear. Accept or reject all changes in Word before extracting anything that matters.

Working through a whole folder

For a large batch, the practical route is ZIP everything, extract, then process. Our ZIP Extractor lists an archive's contents in the browser so you can confirm what you have before pulling files out. If some of the documents are PDFs rather than DOCX, PDF to TXT covers those โ€” but with one important difference: it reads the PDF's text layer, and a scanned PDF has none, so it returns nothing. That is not a failure of the tool; it means the file needs OCR first. Going the other direction, TXT to PDF turns extracted or generated text back into a shareable document.

Frequently asked questions

Can I extract text from a .doc file?

Not directly โ€” the old binary format is a different thing entirely. Open it in Word or LibreOffice and save as .docx, then extract.

Why is the output missing text I can see in Word?

It is probably in a text box, a header or footer, SmartArt, or a footnote. All of these live outside the main document body in the XML.

Does extraction preserve the reading order of columns?

It follows the order in the XML, which for normal multi-column layouts is the correct reading order. Complex layouts built from text boxes can come out in an order that surprises you.

How do I get Markdown rather than HTML?

Convert to HTML first, then run it through an HTML to Markdown step. Going straight from DOCX to Markdown loses more, because HTML is the closer intermediate.

Is there a size limit?

It runs in your browser, so the limit is your machine's memory. Documents of a few hundred pages are fine; a thousand-page file with embedded images may be slow.

Is the document uploaded to a server?

No. The archive is unzipped and the XML parsed in your browser, which matters for contracts, HR files and anything else confidential.

Tools mentioned in this guide