How to Fix “The Name in the End Tag” Error in Microsoft Word

·
6 min read

Help Desk Geek is reader-supported. We may earn a commission when you buy through links on our site. Learn more.

Word refuses to open your DOCX file and shows “The name in the end tag of the element must match the element type in the start tag.” An opening tag and a closing tag don’t match inside the document’s XML, but the content is usually still recoverable.

Fix #1: Use Word’s Open and Repair option

Word can repair minor XML damage without changing the original file. Start here.

  1. Create a copy of the damaged DOCX file and work with the copy.
  2. Open Microsoft Word without opening the document.
  3. Select File > Open > Browse.
  4. Select the damaged document.
  5. Click the arrow beside Open, then select Open and Repair.
Microsoft Word Open dialog with a DOCX file selected and the Open drop-down showing Open and Repair

Word should open the repaired document. Save it immediately under a new name, close Word, and open the new copy again to confirm it works.

Full Microsoft Word error dialog showing "The name in the end tag of the element must match the element type in the start tag" with the Location details and OK button visible

If the error returns, continue with another repair method.

Fix #2: Resave the document in LibreOffice Writer

LibreOffice Writer uses a different DOCX parser and can sometimes open files Word rejects. Resaving the document creates a new XML structure around the recovered content.

  1. Install the current version of LibreOffice from its official website.
  2. Open LibreOffice Writer.
  3. Select File > Open.
  4. Choose a copy of the damaged DOCX file.
  5. Check the document for missing equations, text boxes, images, or formatting.
  6. Select File > Save As.
  7. Choose Word 2007-365 (.docx) as the file type.
  8. Enter a new filename and select Save.
  9. Confirm that you want to use the Word format if LibreOffice displays a compatibility warning.

The new DOCX should open in Word. So far, so good, but compare important equations and page layouts with any PDF or printed copy you have.

Fix #3: Resave the document through Google Docs

Google Docs can rebuild the DOCX package during import and export. Skip this method if the document contains private information that you can’t upload to a cloud service.

  1. Open Google Drive in your browser.
  2. Select New > File upload.
  3. Upload a copy of the damaged DOCX file.
  4. Right-click the uploaded file.
  5. Select Open with > Google Docs.
Google Drive showing a DOCX file's Open with menu with Google Docs highlighted
  1. Check whether the text and key objects loaded correctly.
  2. Select File > Download > Microsoft Word (.docx).
  3. Open the downloaded file in Word.

The downloaded copy should open without the tag mismatch. Check equations, comments, tracked changes, and floating objects because Google Docs may alter complex Word formatting.

Fix #4: Repair the document.xml file manually

A DOCX file is a ZIP archive containing XML files. Manual repair gives you more control, but I’d skip this step unless Open and Repair and both resave methods failed.

Show file extensions and open the DOCX package

  1. Create another copy of the damaged document.
  2. Open File Explorer.
  3. Select View > Show > File name extensions.
Windows 11 File Explorer View > Show menu with File name extensions enabled
  1. Rename the copied file from Document.docx to Document.zip.
  2. Select Yes when Windows warns that changing the extension may make the file unusable.
Windows 11 File Explorer showing a copied Word document renamed from Document.docx to Document.zip with file extensions visible
  1. Right-click the ZIP file and select Extract All.
  2. Open the extracted folder.

You should see folders such as _rels, docProps, and word, plus XML files at the package’s top level.

File Explorer showing the extracted DOCX package with _rels, docProps, and word folders plus XML files

Find the mismatched XML tag

  1. Open the word folder.
  2. Locate document.xml.
Windows 11 File Explorer showing the word folder of an extracted DOCX package with document.xml highlighted
  1. Create a backup copy of document.xml.
  2. Open the working copy in an XML-capable editor such as Visual Studio Code or Notepad++.
  3. Use the location shown in Word’s error dialog, such as Part: /word/document.xml, Line: 2, Column: 12345, to find the damaged section.
  4. Run the editor’s XML validation or formatting command to identify the mismatched opening and closing tags.
  5. Correct only the mismatched tag or misplaced element.
  6. Save document.xml.

DOCX XML is often stored on one long line, so Word may report line 2 with a very large column number. Search near that position for equation elements such as m:oMath, especially when the paragraph also contains an anchored text box or graphic.

Each opening element must have the correct closing element. For example, <m:oMath> must eventually close with </m:oMath> in a valid position. Don’t delete namespace declarations or unrelated XML to make the validation warning disappear.

Rebuild the DOCX file

  1. Return to the folder containing [Content_Types].xml and the extracted package folders.
  2. Select everything inside that folder.
  3. Right-click the selection and choose Compress to ZIP file.
  4. Rename the new archive from .zip to .docx.
  5. Open the rebuilt DOCX file in Word.

The archive must contain [Content_Types].xml at its top level. If you compressed the parent folder instead, Word won’t recognize the result as a valid document.

If the file opens, save it under a new name and reopen it once. That second test confirms Word can parse the repaired XML after saving.

Fix #5: Prevent the tag mismatch from returning

This damage is associated with equations stored in the same paragraph as anchored text boxes or graphics. After recovering the document, separate those objects and update Word before editing further.

  1. Open Word and select File > Account.
  2. Select Update Options > Update Now.
  3. Let Word install available Microsoft 365 or Office updates.
  4. Reopen the recovered document.
  5. Select Home > Select > Selection Pane. The label or ribbon position may vary slightly with your current Word version and selected object.
Current Microsoft Word Home ribbon with Select menu open and Selection Pane highlighted
  1. Select each text box or graphic near an equation in the problem section. Hold Ctrl when you need to select multiple objects.
Microsoft Word Selection Pane listing multiple text boxes with several objects selected
  1. Move the equation or anchored object into a separate paragraph.
  2. If several related text boxes need to stay together, select them and use Word’s Group command. Its ribbon tab and placement depend on the selected object and current Word version.
Current Microsoft Word window with multiple text boxes selected and the Group command visible on the object formatting ribbon
  1. Save the document under a new filename.
  2. Close Word and reopen the saved file.

The document should now open without the error. Keep equations and anchored graphics in separate paragraphs when changing the layout later.

When the fixes don’t work

A professional document-repair service or a dedicated DOCX repair utility may recover content when document.xml has widespread damage. If an older copy opens, restoring that version is safer than making broad XML changes.

Conclusion

Fix #1, Word’s Open and Repair, usually works when the XML damage is limited and is the solid choice to try first. Repeated errors after resaving point to a damaged equation or anchored object, while several broken files from the same drive can indicate storage trouble that needs attention. For more information on repairing corrupted files, you can visit What Is a Corrupted File and How Can I Fix It? or The Ultimate Guide to Repairing a Damaged or Corrupt Word File. You can also read Microsoft’s troubleshooting article on the end tag error for background on the equation and text box cause.