Glossary
DOCX
The default Microsoft Word document format since 2007: a ZIP archive of XML files that store text, formatting, tables, images and metadata.
A DOCX file is a Microsoft Word document saved in the Office Open XML format, the default for Word since 2007. Despite looking like a single file, a DOCX is a ZIP archive containing a set of XML files that describe the document’s text, formatting, tables, images, comments and metadata. Because the structure is open and text-based, software can read and write DOCX files without Word, which makes them one of the easier formats to extract for search and AI.
Where DOCX came from
Before 2007, Word saved documents in the binary .doc format, a proprietary structure that was hard for other software to read reliably. With Office 2007, Microsoft moved to Office Open XML, standardised as ECMA-376 in 2006 and later as ISO/IEC 29500. The same family covers Excel workbooks (.xlsx) and PowerPoint presentations (PPTX). The x in each extension marks the XML-based version.
Today DOCX is the most common format for editable business documents: contracts, proposals, policies, reports, CVs and internal wikis exported from other tools. Google Docs, LibreOffice and Apple Pages all open and save it, so it has become the working format for text that is still being edited, while PDF is usually the format for text that is finished.
What is inside a DOCX file
Rename a DOCX to .zip and open it, and you will find a small directory tree. A file called [Content_Types].xml lists the parts and their types. The word folder holds the content: document.xml contains the body text, styles.xml the named styles, numbering.xml the list definitions, and further parts hold headers, footers, footnotes, comments and settings. Images and embedded objects sit in word/media. The docProps folder carries metadata such as title, author, creation date and last modified date. Relationship files tie the parts together.
The body uses a markup language called WordprocessingML. A document is a sequence of paragraphs (w:p elements), each paragraph contains runs (w:r) of text that share formatting, and each run holds the characters themselves in w:t elements. Tables are w:tbl elements with rows and cells, and each cell contains paragraphs of its own. Headings are ordinary paragraphs with a heading style applied, and lists are paragraphs linked to a numbering definition.
The metadata in docProps deserves a mention of its own. Core properties record the author, the last person to modify the file, a revision count and timestamps, and custom properties can hold whatever an organisation’s templates add, such as a document ID or a classification. Metadata extraction can read these directly, which helps with filtering and provenance, but they can also leak names and internal details when documents are shared outside the organisation. Word’s fuller version history lives outside the file, in SharePoint or OneDrive, so the DOCX itself holds only the current state plus any tracked changes.
This structure is the reason a DOCX is easier to work with than a PDF. The file records paragraphs, tables, headings and reading order explicitly, so there is no need to reconstruct them from positioned glyphs as PDF parsing must. Text is always real text, never an image, so there is no PDF text layer to check and no OCR step for the body.
What makes DOCX extraction harder than it looks
The structure is clean in principle and messy in practice. A single word can be split across several runs because of formatting changes, spell-check markers or revision history, so naive extraction can produce broken words unless runs are joined. Tracked changes are stored inline as insertions and deletions, which means an extractor has to decide whether to show the document as it was, as it is proposed, or both. Comments live in a separate part, linked by anchors, and are easy to lose.
Other content hides in places a simple reader skips. Text boxes and shapes sit in drawing markup rather than the main paragraph flow. Headers and footers are separate parts that repeat on every page when printed. Fields, such as tables of contents, cross-references and dates, store both an instruction and the last calculated result. Embedded charts, spreadsheets and images carry their own content, and images may contain text that needs OCR to read.
Page numbers are another trap. A DOCX does not store pages; Word lays out pages when it renders the document, and the result depends on fonts, printer settings and the application. Any page number an extractor reports for DOCX content is an estimate, unless the document is first converted to PDF. That matters when a system needs to cite a precise location, and it is one of the practical differences covered in DOCX vs PDF.
DOCX in AI and RAG pipelines
For retrieval augmented generation, DOCX is a good source format because its structure survives extraction. Headings give natural section boundaries for chunking, tables can be kept as tables rather than flattened into lines, and list items stay grouped. Converting a DOCX to Markdown preserves most of this structure in a form language models read well, while converting to JSON gives code a predictable shape to work with.
The quality of what comes out depends on decisions made at extraction time. Should tracked changes be accepted or shown? Should comments be included as context or dropped? Should headers and footers repeat in every chunk, appear once or be removed? Should text inside images be recognised? A policy document with heavy tracked changes, for example, can produce chunks containing both old and new wording side by side, which confuses retrieval and produces answers that quote superseded terms. Most teams accept changes and drop deleted text for the indexed version, and keep the original file for review.
Structure also helps with table extraction. Tables in a DOCX are explicit, with merged cells marked, so rows and columns can be rebuilt reliably, unlike PDF tables where the grid has to be inferred from lines and spacing. Pipelines that pull specific fields from documents, such as contract extraction or resume parsing, often see higher accuracy on DOCX inputs than on scanned equivalents for exactly this reason.
Identifying and handling DOCX files
A DOCX file’s MIME type is application/vnd.openxmlformats-officedocument.wordprocessingml.document. Because the file is a ZIP archive, its first bytes look like any other ZIP, so file type detection has to open the archive and look for word/document.xml to confirm it. The same check distinguishes it from XLSX, PPTX and EPUB files, which share the container.
Several related formats need different handling. The older binary .doc format is not a ZIP and needs a different parser. Macro-enabled documents use the .docm extension and can contain VBA code, which is a common route for malware, so upload paths usually block them or scan them. Flat OPC files store the same XML in a single file without the ZIP wrapper. Strict OOXML, a variant of the standard, uses different namespaces and is rare in practice but breaks some parsers.
Common open-source tools for reading DOCX include python-docx for paragraph and table access, Pandoc for conversion to Markdown and HTML, Mammoth for clean HTML output, and LibreOffice for converting to PDF when page layout matters. Each handles the edge cases above differently, which is why teams that need consistent output across many sources often move to a managed extraction service. Open-source options are compared in the best open source document parsers and in Exabase vs Docling.
A worked example
Picture an HR team building an assistant over 1,200 policy documents, most of them DOCX files maintained in a shared drive. A first pass extracts plain text with a simple library. The assistant answers well on short policies, but on longer ones it quotes clauses that were deleted months ago, because tracked changes were extracted as ordinary text. It also misses the holiday allowance table, which was flattened into a run of numbers, and repeats the footer “Internal use only” in every chunk.
A second pass accepts tracked changes, keeps tables as Markdown tables, removes repeated headers and footers, and splits chunks at heading boundaries. Chunks now line up with policy sections, retrieval returns the current wording, and table questions such as “how many days of leave after five years” work. The documents did not change; the extraction decisions did. Keeping the knowledge base current as policies are edited is a separate job, which the knowledge bases use case covers.
Where Exabase fits
Exabase Extract accepts Word documents through the same POST /v2/extract endpoint as PDFs, images, audio, video and web pages, detects the type automatically, and returns structured JSON with metadata, a thumbnail and the text split into chunks. Adding ?format=markdown returns the same result as a readable Markdown document for a prompt. The submitting jobs guide shows the request, and the DOCX to JSON and DOCX to Markdown tools let you try a single file.
Saved as Resources, Word documents are indexed on arrival and searchable through Deep Search, which returns the matching passage rather than the whole file. When the same documents keep changing, the knowledge base solution uses a Worker to re-extract them on a schedule, so answers follow the current version. Exabase provides the extraction and retrieval layer; deciding how a business process such as contract analysis uses the extracted text stays with your application. The broader pattern is described in the file extraction solution and in parsing is a product you didn’t mean to build.
Frequently asked questions
What is a DOCX file?
A DOCX file is a Microsoft Word document in the Office Open XML format: a ZIP archive of XML files holding the text, formatting, tables, images and metadata. It has been Word’s default format since 2007.
What is the difference between DOC and DOCX?
DOC is the older binary Word format used before 2007, while DOCX is the XML-based format that replaced it. DOCX files are smaller, easier for other software to read and based on an open standard.
How do I extract text from a DOCX file?
Use a library such as python-docx or a converter such as Pandoc, or an extraction API that returns text and structure as JSON or Markdown. Decide up front how to handle tracked changes, comments, headers and text inside images.
Does a DOCX file have page numbers?
No, not in the file itself. Pages are calculated when the document is rendered, so they vary between applications and settings. Convert the document to PDF if you need fixed page references.
Can a DOCX file contain malware?
Standard DOCX files cannot contain macros, but macro-enabled .docm files can, and both can embed objects or links. Detect the real file type, block or scan macro-enabled files, and treat embedded content with care.
Is DOCX better than PDF for RAG?
For editable source documents, DOCX usually extracts more cleanly, because headings, lists and tables are stored explicitly. PDF is better when you need fixed page numbers for citations or when the document is final.
Does Exabase support DOCX files?
Yes. Exabase Extract processes Word documents through the same endpoint as other file types and returns text chunks, metadata and a thumbnail, as JSON or Markdown.
Related pages: DOCX vs PDF, PPTX, EPUB, MIME type, Document extraction, Chunking, DOCX to JSON, File extraction, Which file types AI apps ingest, Best document extraction API