Manatee

Fixing a DOCX that Word says is corrupt

A DOCX is a ZIP archive full of XML, so “the file is corrupt” almost always means one of two things: the archive’s index is damaged, or the main document.xml inside it has been cut short or malformed. Both are fixable more often than Word’s error suggests. Try a different app first, then rebuild the archive by hand or let a repair tool do it, and as a last resort extract the raw text from inside the file.

What Word actually means by “corrupt”

Before Word opens a .docx it checks that the archive’s central directory (the table of contents at the end of a ZIP) matches the files inside, and that every XML part is well formed. If one byte in that chain is wrong, you get “Word found unreadable content” or “The file is corrupt and cannot be opened”, even when 99 percent of your document is intact.

The most common causes, in rough order:

  • The file was copied to a USB stick, a network share or a syncing folder and the copy was interrupted, so the tail of the archive (where the index lives) never arrived.
  • Word was force-quit, or the Mac lost power, while it was writing the file.
  • The document was emailed or downloaded and something in the chain mangled it, often by treating it as text.
  • It is not a DOCX at all: an old binary .doc, an RTF or a PDF that someone renamed.

Before anything else, duplicate the file in Finder (select it, press Command+D) and work on the copy. Some of the steps below are not reversible.

Step 1: open it in something that is not Word

Other apps read DOCX with a more forgiving parser. Pages in particular will open files Word refuses, and so will TextEdit for simple documents.

  1. Right-click the file in Finder and choose Open With, then Pages. If it opens, choose File, Export To, Word to write a clean new .docx.
  2. If Pages fails, try Open With, TextEdit. Formatting will be rough, but you get the text.
  3. Press Space with the file selected in Finder. Quick Look uses its own parser; if the preview renders, the content is still in there.

If any of these opens the file, you are done: save a fresh copy and move on.

Step 2: check whether it is really a DOCX

Open Terminal (Applications, Utilities) and drag the file onto the window after typing file with a trailing space:

file ~/Desktop/report.docx

A healthy document reports “Microsoft Word 2007+”. If you see “Microsoft Office Document” or “Composite Document File”, it is a legacy .doc with the wrong extension; rename it to .doc and Word will open it. “Rich Text Format” means rename to .rtf. “data” with no further detail is the worrying one: either the ZIP header is gone or the file is empty. Check its size in Get Info; a 0 KB or 4 KB file for a ten-page report means the content was never written, and no tool can repair what was never saved.

Step 3: rebuild the archive, or pull the text out

Because a DOCX is a ZIP, the tools that ship with macOS can inspect it.

Test and rebuild the archive

  1. In Terminal, test the archive:

unzip -t ~/Desktop/report.docx

If every entry says OK, the container is fine and the problem is inside the XML (skip to the text extraction below). If you see “End-of-central-directory signature not found”, the index is missing, which usually means a truncated copy.

  1. Try to extract what is there anyway:

mkdir ~/Desktop/report-parts cd ~/Desktop/report-parts unzip ../report.docx

unzip will warn about the damaged parts and extract the rest.

  1. Look inside the folder. You want [Content_Types].xml, a word folder containing document.xml, and _rels. If word/document.xml is present and larger than a few kilobytes, your text survived.

  2. Re-zip it from inside the folder, so the paths stay at the root of the archive:

zip -r -X ../report-fixed.docx .

  1. Open report-fixed.docx in Word.

If Word still complains, open word/document.xml in TextEdit and scroll to the end. A good file ends with </w:body></w:document>. A truncated file stops mid-tag. You can often close it by hand: delete the incomplete final paragraph back to the last </w:p>, then append </w:body></w:document>, save, and re-zip. It is fiddly, and you lose anything after the cut, but it works.

Pull the text out when the structure is gone

If the archive is too damaged to rebuild, the words themselves are usually still readable. Strip the XML tags:

unzip -p ~/Desktop/report.docx word/document.xml | sed 's/<[^>]*>/ /g' > ~/Desktop/report-text.txt

You lose headings, bold, tables and images, but you get every sentence in order. Paste it into a new document and re-apply formatting. Images live in word/media inside the archive, so the same unzip extraction from Step 3 recovers them as ordinary PNG and JPEG files.

Step 4: let Manatee do the rebuild for you

If you would rather skip the Terminal, Manatee does the same container work in one drop. Drag the .docx onto its menu bar icon or window, pick Repair, and it reads the archive entry by entry, salvages what is intact, and writes a new document next to the original. It never touches the original file.

The result is labeled honestly. Fixed means Word opens the new copy cleanly. Partial means some parts could not be read (you will see what was recovered). Not fixable means the archive holds nothing usable, typically because the file was empty or truncated at the very start. It cannot invent content that was never written to disk, and it does not recover a document you deleted; it only works on the bytes in front of it. Everything runs on your Mac, so a confidential contract stays on your Mac. It is free for 24 hours with every feature, then $9 once.

For the wider picture of what repair can and cannot achieve, see why files get corrupted and what can actually be recovered.

Step 5: find a copy you forgot you had

Check these:

  1. Word’s AutoRecovery folder. In Finder press Command+Shift+G and paste ~/Library/Containers/com.microsoft.Word/Data/Library/Preferences/AutoRecovery. Sort by date.
  2. If the file lives in iCloud Drive, OneDrive or Dropbox, the web versions keep previous revisions for weeks.
  3. Time Machine, if it is on: open the folder in Finder, then Enter Time Machine.
  4. Sent Mail, if you ever emailed an earlier draft.

A day-old copy plus the text extracted in Step 3 is often a faster path than a perfect repair.

Keeping it from happening again

Save with Command+S before ejecting a drive or closing the lid, wait for the sync icon to settle before moving a file out of a cloud folder, and keep AutoRecover on (Word, Preferences, Save). When a document matters, File, Save a Copy to a second place once a day. A corrupt DOCX is nearly always a write that never finished.

If the file is a .doc rather than a .docx, the approach differs; see how to recover a Word document that won’t open on Mac.

Questions

Word opens the repaired file but the images are missing. Where did they go? Images live in word/media inside the archive and are referenced from word/_rels/document.xml.rels. If the rels file was damaged, Word cannot match pictures to their positions. Extract the archive (Step 3) and you will find the images as ordinary files; reinsert them by hand.

Can I fix the file on my iPhone or in Word Online instead? Sometimes. Word’s web version uses a different parser and occasionally opens a file the Mac app rejects. Upload it, and if it opens, download a fresh copy. Be aware that uploading means the document leaves your machine.

The file is 0 KB. Is anything recoverable? No. A 0 KB file contains no bytes, so there is nothing to repair. Your options are AutoRecovery, cloud version history, Time Machine or an earlier emailed draft.

Does Manatee repair the old .doc format too? It accepts .doc as an input and can convert it, but the container repair described here applies to .docx, .xlsx, .pptx and similar ZIP-based formats. For a damaged binary .doc, the recovery post linked above covers the options.