How to Inspect XML Inside DOCX and XLSX Files
Modern Microsoft Office formats, such as .docx and
.xlsx, are packaged archives based on the Office Open XML
(OOXML) standard. Instead of a single binary file, they consist of a
collection of structured XML documents, relationship manifests, and
embedded media compressed into a standard ZIP container. This guide
details how to access, extract, and inspect these underlying XML
structures using built-in operating system tools, archive managers, and
specialized developer software.
Method 1: The Rename-and-Unzip Approach
The most straightforward way to view the XML contents without third-party software is by changing the file extension.
- Create a Backup: Make a copy of your
.docxor.xlsxfile to avoid modifying or corrupting the original document. - Change the Extension: Rename the file extension
from
.docxor.xlsxto.zip(e.g.,document.docxbecomesdocument.zip). If file extensions are hidden, enable “File name extensions” in your operating system’s folder options. - Extract the Archive: Use your system’s built-in extraction tool (such as Windows File Explorer or macOS Archive Utility) or any standard unzipping tool to extract the contents into a new folder.
- View the Files: Open the extracted folder to browse the XML files.
Understanding the Directory Structure
Once extracted, the folder contains several standardized subdirectories and XML files:
[Content_Types].xml: Located in the root directory, this file defines the MIME types for all components within the package._rels/: Contains.relsfiles that define how the various parts within the package relate to each other.word/(for.docx) orxl/(for.xlsx): The primary payload folder.- In Word:
document.xmlcontains the main text and body formatting, whilestyles.xml,settings.xml, andfontTable.xmlstore document configuration. - In Excel:
workbook.xmldefines the overall workbook structure, while theworksheets/subfolder contains individual XML files for each sheet (e.g.,sheet1.xml). ThesharedStrings.xmlfile stores text values to optimize file size.
- In Word:
docProps/: Contains metadata files such ascore.xmlandapp.xml, which store author information, creation dates, and statistics.
Method 2: Direct Inspection via Archive Managers
If you frequently inspect documents, renaming extensions can be inefficient. Third-party archive utilities (such as 7-Zip, WinRAR, or PeaZip) can inspect the package directly:
- Right-click the
.docxor.xlsxfile. - Select your archive manager’s option to Open Archive without renaming the file.
- Double-click any
.xmlfile to view it in your default text editor, or drag specific files out to examine them.
Method 3: Using Code Editors and Extensions
Modern code editors simplify browsing and formatting the underlying XML:
- Visual Studio Code: Extensions like Open OOXML or Zip File Explorer allow you to open Office files directly in the editor, navigate the internal directory tree, and format/prettify the minified XML files for easy reading.
- Open XML SDK Productivity Tool: A dedicated tool from Microsoft that allows developers to inspect, validate, and reverse-engineer OOXML structures directly into C# code.