Why your .docx opens as XML
A Word file is a zip archive full of XML, so seeing tags is not in itself a fault — it means something stopped Word unpacking it for you. There are four different problems that look like this and their fixes have nothing in common, so the first job is telling them apart. That starts with what the file actually is, which its first few bytes say and its extension does not.
A .docx is a zip file full of XML. That is not a fault — it is what the format is — so seeing XML means something has stopped Word from unpacking it for you: the file arrived renamed, it was served with the wrong type, it is genuinely damaged, or Word has decided one line inside it is malformed and is refusing the whole document. The first thing to establish is which, because the fixes have nothing in common. X-RAY opens the file in your browser and says what it actually is and what is in it, without uploading it and without you renaming anything.
What you are looking at
Since 2007, every Office file is a zip archive. Rename report.docx to report.zip, open it, and you find a folder of XML documents: word/document.xml holds the text, word/styles.xml the formatting, docProps/core.xml the author and timestamps, and [Content_Types].xml the index that tells a reader what all the other parts are.
So "my docx opened as XML" is usually one of four different things wearing the same appearance.
Which of the four you have
| What you see | What it is | Fix |
|---|---|---|
A wall of <?xml ...> and tags in Notepad or a browser | The file is fine; something opened it as text instead of handing it to Word | Open with → Word. Check the extension is really .docx |
| Word: "cannot be opened because there are problems with the contents" | Word's XML parser hit something it will not accept, often one tag, often after a crash or a sync conflict | Open and Repair, then the salvage route below |
| Word: "the file appears to be corrupted" on a file from email or a download | Frequently not corrupt: a transfer damaged it, or it was never a docx | Check what the file actually is before repairing anything |
| The document opens but shows the markup as text | A .doc, .rtf or XML file renamed to .docx | Rename it to what it is, or open it as that type |
Start by asking what the file is
Almost every guide to this begins by telling you to repair the file. That is the second step. The first is to find out whether it is a Word document at all, because an extension is a suggestion and the bytes are the fact.
Every file type announces itself in its first few bytes. A zip — and therefore any real .docx — starts with PK, after Phil Katz, who wrote the format. An old .doc starts with D0 CF 11 E0. An RTF starts with the literal text {\rtf1. A PDF starts with %PDF-. If somebody exported "as Word" from a system that actually produced RTF, or saved a web page and renamed it, the extension will say docx and the bytes will not.
Drop the file into X-RAY and it reads those bytes and tells you what it really is, then lists what is inside: the author, the editing time, the tracked changes and comments still in it, and whether anything in the document reaches out to a server when opened. It is all done in the tab, and the file is not uploaded — which matters when the document is somebody's contract and the thing you are trying to do is open it, not publish it.
If it really is a docx and Word will not have it
- Open and Repair. In Word: File → Open → Browse, select the file, then the arrow beside the Open button → Open and Repair. It fixes a useful proportion of real damage and costs nothing to try.
- Open the text directly. Copy the file, rename the copy to
.zip, open it, and take outword/document.xml. Even when Word refuses the document, the words are usually all in there — buried in markup, but recoverable by eye or by stripping the tags. This is the step most guides lead with, and it is worth knowing; it is also the one where people start hand-editing XML in Notepad, which mostly produces a second broken file. - Try a different reader. LibreOffice is markedly more forgiving than Word about malformed Office XML and will often open a file Word has rejected. Docs here will open a
.docxin your browser, and REFLOW exists for getting editable text back out of a document that has become a PDF along the way. - Look for the version before the damage. A file that broke during a sync or a crash usually has an intact predecessor: OneDrive and SharePoint keep version history, Word keeps AutoRecover files, and the folder may hold a
~$owner file or a.tmpfrom the same session. This is a far better use of an hour than repairing XML by hand.
Before you pay for repair software
Two of the results you will find for this are companies selling document recovery. They are not frauds and they do sometimes work, but be clear about the order of things: try Open and Repair, try LibreOffice, try the version history, and look inside the zip — all free and all fast — before you buy anything. And do not upload the document to a web-based repair service to find out whether it can be fixed. Whatever the document is, that is a copy of it on somebody else's computer, and it is a strange trade to make for a file you have not been able to read yourself.
The thing worth knowing afterwards
Once you understand that a Word file is a zip of XML, the other consequence follows: everything in those parts travels with the document whether you can see it in Word or not. The author's name and the organisation, the total editing time, the revision count, every comment, every tracked change including the deleted text, and often earlier drafts of what you replaced. What is hidden in a Word document goes through the whole list, and SCRUB takes it out before you send the file on.
Questions people ask about a .docx that opens as XML