---
title: "Extract text from Word document"
method: POST
path: "/docx/to-text"
tags: ["Word"]
---

# Extract text from Word document

`POST /docx/to-text`

## Request

- Base URL: `https://api.filegraph.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.filegraph.ai/docx/to-text`
- Auth: API key in header `X-API-Key`

Extract all text content from a Microsoft Word document.

Extracts text from:
- Document body
- Headers and footers
- Tables
- Text boxes

## Example Usage

```python
import httpx

with open("report.docx", "rb") as f:
    response = httpx.post(
        "https://api.filegraph.ai/docx/to-text",
        headers={"X-API-Key": "your-api-key"},
        files={"file": f},
    )
print(response.json()["text"])
```

## Response `200`

Successful Response

- TextExtractionResponse: Response for text extraction endpoints.
  - `text` string, required: Extracted text content
  - `format_detected` string, required: Detected input format (e.g., 'pdf', 'docx', 'image')
  - `word_count` integer, required: Number of words extracted
  - `char_count` integer, required: Number of characters extracted
  - `used_ocr` boolean, required: Whether OCR was used for extraction
  - `metadata` object: Additional format-specific metadata

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/filegraph/apis/docconvert-api.md) · [All operations](https://skmtc.dev/filegraph/apis/docconvert-api/llms.txt) · [OpenAPI document](https://skmtc.dev/filegraph/apis/docconvert-api/revisions/436255c85bd4?raw)
