DOCX to Markdown

Layout-aware, paged Markdown conversion for document agents and RAG.

Open-source library

Loading converter…

Use it in your application

Available as TypeScript and Python packages.

npm install @docx-editor.dev/docx-to-markdown @docx-editor.dev/core
View on npm

Add the converter to your TypeScript or JavaScript application. Includes the required core dependency.

Install the docx-to-markdown package

TypeScript and Python packages powered by our own DOCX layout engine. Run in Node.js, browsers, or Python. Get Markdown, images, and per-page metadata in one call.

npm install @docx-editor.dev/docx-to-markdown @docx-editor.dev/core
import { readFile } from 'node:fs/promises';
import { exportMarkdown } from '@docx-editor.dev/docx-to-markdown';

const bytes = await readFile('document.docx');
const result = await exportMarkdown(bytes, { images: true });

console.log(result.markdown);

for (const page of result.pages) {
  console.log(page.number, page.markdown);
}
TypeScriptServer setup

Server-side and serverless conversion

Process DOCX files in a Node.js application or serverless function. Bundle the required fonts and WebAssembly assets. Microsoft Word and a hosted conversion service are not required.

Convert files in a Next.js function ↗

Client-side conversion

Convert files directly in a TypeScript application. Keep document bytes in the browser and return Markdown, page data, and images using the same API.

Set up browser conversion ↗

DOCX conversion as a service.

Send a document. Get Markdown and page JSON. Works with n8n, scripts, and your app.

Preparing your API key…

DOCX to Markdown API

Generating a private trial key for this browser.

TypeScript-first, down to the layout engine.

Our own DOCX engine calculates the layout before exporting Markdown. You get page context, headers and footers, and image dimensions from the same engine that powers DOCX Editor ↗. Built and maintained by our team, from layout to export.

result.pages

Extract Markdown by page

Associate extracted text with its source page for search results and RAG citations. Read headers and footers separately from the document body.

Work with pages ↗
result.media

Convert Word files with images

Export image files alongside Markdown, with paths and page occurrences. Use HTML image tags when you need displayed width and height. Download both in a ZIP.

Export images ↗
result.reviewArtifacts

Export comments and tracked changes

Choose original, proposed, or marked-up text. Read comments and revisions as structured data to build document review and ingestion workflows.

Explore the API ↗

Before you integrate

How do I convert a Word document to a .md file?

Open a .docx file in the converter above. Compare the Word document with the Markdown preview, then copy the output or download it. For conversion in your application, pass the file bytes to exportMarkdown().

Is the DOCX to Markdown library open source?

Yes. The library is open source under Apache 2.0, including image, comment, and tracked-change extraction. Bundled fonts retain their own licenses. The interactive editor demo includes separately licensed Pro review controls.

Can I use JavaScript, TypeScript, or Python?

Yes. The npm package includes TypeScript declarations and supports JavaScript imports in Node.js and browsers. The docx-to-markdown package on PyPI provides the same converter for Python 3.11 or later.

Can I run conversion in a serverless function?

Use a Node.js runtime with WebAssembly support and include the required font and WASM files in the function bundle. Set memory, upload-size, and execution limits for your workload. Next.js Edge is not supported.

Does client-side conversion upload my document?

The demo processes document bytes in your browser. No document upload is required for conversion. Fonts and WebAssembly assets must be available to the browser; fallback fonts can require network requests.

Does Markdown preserve the Word layout?

Markdown preserves document structure, not every visual detail. The layout engine calculates pages before export, so you can associate text and images with a page. Fonts and document features can change page breaks compared with Microsoft Word. Floating text wrapping, image cropping, and rotation are not reproduced in Markdown.

How do fonts affect DOCX to Markdown conversion?

Fonts determine text widths and page breaks, even though Markdown does not retain font styling. The package includes substitutes for common Word fonts. Use fonts to supply the document’s original faces before those substitutes, and fallbackFonts for additional sources afterward. Check result.fontResolution and result.warnings to see what was used. For repeatable pagination, keep the font files and package versions fixed. Configure fonts and fallbacks ↗

Can I convert .doc files?

The library accepts .docx files. Save a legacy .doc file as .docx in Word or another compatible editor before converting it.