convert_to_docx
Convert Markdown text to Microsoft Word DOCX format with styled headings, lists, and code formatting. Generate editable Word documents from structured content for professional editing and distribution.
Instructions
Convert Markdown to a Microsoft Word DOCX file. Produces a binary .docx document with styled headings, bold/italic text, numbered and bulleted lists, and code formatting. This is a binary format — output_path should almost always be provided. Side effects: when output_path is provided, writes the DOCX binary to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns a JSON object with { format: 'docx', file_size_bytes, hint, base64_preview } — the hint will tell you to re-call with output_path to save the file. Returns: JSON write-confirmation (if output_path set), or JSON binary-guidance object (if omitted). Use this for Word-compatible documents. Prefer convert_to_rtf for legacy word processors, convert_to_pdf for read-only distribution, or convert_to_html for web.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| markdown | Yes | The raw Markdown source text to convert. Supports GitHub-Flavored Markdown (tables, task lists, strikethrough) and KaTeX math expressions. Pass the full document content as a string, not a file path. | |
| output_path | No | Optional. Absolute or relative file path (e.g. './output.docx') where the binary file will be saved. Parent directories are created automatically. If provided, the file is written to disk and a JSON summary with { success, file_path, file_size_bytes, format } is returned. If omitted, a JSON object with { format, file_size_bytes, hint, base64_preview } is returned — the hint will instruct you to call the tool again with output_path to save the file. Binary formats (DOCX) should almost always specify output_path. |