Settings

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 seeWhat it isFix
A wall of <?xml ...> and tags in Notepad or a browserThe file is fine; something opened it as text instead of handing it to WordOpen 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 conflictOpen and Repair, then the salvage route below
Word: "the file appears to be corrupted" on a file from email or a downloadFrequently not corrupt: a transfer damaged it, or it was never a docxCheck what the file actually is before repairing anything
The document opens but shows the markup as textA .doc, .rtf or XML file renamed to .docxRename 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

  1. 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.
  2. Open the text directly. Copy the file, rename the copy to .zip, open it, and take out word/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.
  3. 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 .docx in your browser, and REFLOW exists for getting editable text back out of a document that has become a PDF along the way.
  4. 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 .tmp from 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 Why your .docx opens as XML

Why does my .docx open as XML code?

Because a .docx is a zip file full of XML, and something has opened it as plain text rather than handing it to Word. Usually that means the extension is wrong, the file was served with the wrong type, or the file is not actually a Word document. Check what it really is before trying to repair it: X-RAY reads the first bytes and says so.

Is a .docx really a zip file?

Yes. Since Office 2007 every .docx, .xlsx and .pptx is a zip archive of XML parts: word/document.xml holds the text, docProps/core.xml holds the author and timestamps, and [Content_Types].xml indexes the rest. Rename a copy to .zip and you can open it with anything that opens a zip.

How do I get the text out of a .docx Word will not open?

Copy the file, rename the copy to .zip, open it, and take out word/document.xml. The words are almost always intact inside the markup even when Word refuses the document. Strip the tags and you have your text back. Work on a copy, never the original.

What does "there are problems with the contents" mean?

Word's XML parser met something it will not accept: often a single malformed tag, often the result of a crash, a sync conflict or an interrupted save. It is a parser refusing the file rather than a statement that the data is gone. Open and Repair fixes a fair proportion, LibreOffice opens many of the rest, and the text is usually still readable inside the zip either way.

How can I tell what a file actually is if the extension is wrong?

By its first bytes, which every format uses to announce itself. A zip and therefore any real .docx begins with PK; an old .doc begins with D0 CF 11 E0; an RTF begins with {\rtf1; a PDF begins with %PDF-. X-RAY reads them and tells you, in your browser, without the file being uploaded.

Should I edit the XML inside the file by hand?

Rarely, and not first. It is the step most guides lead with and the one most likely to produce a second broken file. Try Open and Repair, then LibreOffice, then the version history your sync service or AutoRecover kept: all free, all faster, and none of them risk the original.

Is it safe to use an online docx repair service?

Only if you are content for that document to exist on somebody else's server. Almost all of them work by upload, and the file you cannot open is still a file that says something: a contract, a statement, a draft. Try the free local routes first, and if you need a tool, use one that reads the file in your own browser.

Will LibreOffice open a file Word cannot?

Often, yes. LibreOffice is noticeably more tolerant of malformed Office XML than Word is, so a document Word rejects outright will frequently open there, sometimes with the damaged part missing and everything else intact. It is free and it is the cheapest thing to try after Open and Repair.

I renamed it to .zip and there is nothing inside. Now what?

Then it was never a zip, which means it was never a real .docx. It is an old .doc, an RTF, an HTML file or something else that was renamed or mislabelled by whatever produced it. Find out what it is from its first bytes and open it as that.

What else is inside a Word file that I cannot see?

The author's name and organisation, the total editing time, the revision count, the timestamps, every comment, every tracked change including the text that was deleted, and often earlier drafts of replaced passages. All of it travels with the document. What is hidden in a Word document lists it and SCRUB removes it.

Related tools

More on this

All 22 guides under “A file that will not open, or comes out wrong”.

A letter, now and then

An occasional letter when there is something worth reading: the new guides and what changed in the tools. Never more than once a month and nothing else, and you can leave at any time on the unsubscribe page.