How to Extract Text from a Word Document (5 Methods)
To extract plain text from Word, save the document as .txt or paste selected content into a plain-text editor. Pandoc and Mammoth offer local DOCX workflows. Choose Markdown when retaining headings and links matters; it is a different output from unformatted text.
Choose an output before the tool
| Method | Output | Useful when |
|---|---|---|
| Word Save As | .txt | You already have Word |
| Copy selected text | Text in an editor | You need a short passage |
| Pandoc | Plain text or Markdown | You want local command-line processing |
| Mammoth | Raw text or HTML | You are building a JavaScript import |
| MDisBetter | Markdown | You want hosted structured conversion |
1. Save Word as plain text
- Open the document in a Word version offering plain-text export.
- Choose Save As or Save a Copy, then Plain Text (.txt).
- Check the encoding preview; UTF-8 is a useful portable choice when offered.
- Save a separate copy and retain the original DOCX.
- Reopen the text file and check tables, lists and non-English characters.
Menu names vary by Word version. Microsoft documents text encoding and saving. Plain text cannot preserve Word page layout, images or rich formatting. Check important document elements rather than assuming all were exported.
2. Copy a selected passage
Paste into Notepad or another plain-text editor and save as .txt. A rich-text destination may retain formatting instead. See Word copy-paste formatting issues for CMS workflows.
Inspect text boxes, footnotes, comments and tables separately when they matter. Content outside your selection can be missing.
3. Use Pandoc locally
After installation, choose the output explicitly:
pandoc -f docx -t plain input.docx -o output.txt
pandoc -f docx -t gfm input.docx -o output.mdThe second command produces Markdown. Retaining image files requires --extract-media and path checks; see the manual.
4. Use Mammoth for JavaScript extraction
After installing Mammoth, a Node.js raw-text example is:
const fs = require("node:fs/promises");
const mammoth = require("mammoth");
async function main() {
const result = await mammoth.extractRawText({ path: "input.docx" });
await fs.writeFile("output.txt", result.value, "utf8");
console.log(result.messages);
}
main().catch(error => { console.error(error); process.exitCode = 1; });Check both text and messages. For structured imports, convertToHtml is a separate method; direct Markdown conversion is deprecated. Consult the maintainer documentation. HTML from untrusted uploads needs appropriate sanitization before rendering.
5. Use a hosted Markdown workflow
Sign in and open Word to Markdown. Upload the DOCX, convert with available credits and download the .md file. Several files can be submitted in the web interface.
This is structured text, not a claim of plain .txt output. Embedded images become generated descriptions, which can contain errors. Compare important facts and tables with the original.
Verify the result
Check the beginning, ending and an important middle passage. Review table cells, list order and any relevant comments or revisions. Keep the original and note omissions.
See PDF, Markdown and TXT as inputs and Word-to-text preparation for representation choices. Other sources need their own routes: PDF extraction and web article extraction.