> ## Documentation Index
> Fetch the complete documentation index at: https://docs.upsonic.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# DOCX Loader

> Load Microsoft Word documents with table and formatting support

## Overview

DOCX loader extracts content from Microsoft Word documents (.docx). Supports extraction of text, tables, headers, and footers with flexible formatting options.

**Loader Class:** `DOCXLoader`

**Config Class:** `DOCXLoaderConfig`

## Install

<Note>
  Install the DOCX loader optional dependency group:

  ```bash theme={null}
  uv pip install "upsonic[docx-loader]"
  ```
</Note>

## Examples

```python theme={null}
from upsonic import Agent, Task, KnowledgeBase
from upsonic.loaders.docx import DOCXLoader
from upsonic.loaders.config import DOCXLoaderConfig
from upsonic.embeddings import OpenAIEmbedding, OpenAIEmbeddingConfig
from upsonic.text_splitter.recursive import RecursiveChunker, RecursiveChunkingConfig
from upsonic.vectordb import ChromaProvider, ChromaConfig, ConnectionConfig, Mode

# Configure loader
loader_config = DOCXLoaderConfig(
    include_tables=True,
    include_headers=True,
    table_format="markdown"
)
loader = DOCXLoader(loader_config)

# Setup KnowledgeBase
embedding = OpenAIEmbedding(OpenAIEmbeddingConfig())
chunker = RecursiveChunker(RecursiveChunkingConfig())
vectordb = ChromaProvider(ChromaConfig(
    collection_name="docx_docs",
    vector_size=1536,
    connection=ConnectionConfig(mode=Mode.IN_MEMORY)
))

kb = KnowledgeBase(
    sources=["document.docx"],
    embedding_provider=embedding,
    vectordb=vectordb,
    loaders=[loader],
    splitters=[chunker]
)

# Query with Agent
agent = Agent("anthropic/claude-sonnet-4-5")
task = Task("Extract key points from the document", context=[kb])
result = agent.do(task)
print(result)
```

## Parameters

| Parameter | Type | Description | Default | Source |
| - | - | - | - | - |
| `encoding` | `str \| None` | File encoding (auto-detected if None) | None | Base |
| `error_handling` | `"ignore" \| "warn" \| "raise"` | How to handle loading errors | "warn" | Base |
| `include_metadata` | `bool` | Whether to include file metadata | True | Base |
| `custom_metadata` | `dict` | Additional metadata to include | {} | Base |
| `max_file_size` | `int \| None` | Maximum file size in bytes | None | Base |
| `skip_empty_content` | `bool` | Skip documents with empty content | True | Base |
| `include_tables` | `bool` | Include table content | True | Specific |
| `include_headers` | `bool` | Include header content | True | Specific |
| `include_footers` | `bool` | Include footer content | True | Specific |
| `table_format` | `"text" \| "markdown" \| "html"` | How to format tables | "text" | Specific |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.