Skip to content
Projects

md2docx/md2docx has 41 GitHub stars and 6 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-09 20:03 UTC. Last push 2026-11-05.

How these counts are measured

The modular document compiler ecosystem to transform Markdown and ASTs into high-fidelity DOCX documents.

Measured star growth

in 24h
0
in 7 days
Update delayed
in 15 days
Update delayed
in 1 month
Update delayed

Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.

README.md

Original

Md2Docx

Md2Docx Banner

CI codecov npm version npm downloads npm bundle size license npm bundle size

Md2Docx: A powerful, pluggable, and extensible Markdown to Microsoft Word (.docx) document engine for Node.js and browsers, backed by a rich suite of official plugins.


✨ Why Md2Docx?

Modern applications, technical platforms, and Generative AI tools produce structured output in Markdown. Md2Docx transforms Markdown Abstract Syntax Trees (MDAST) into professionally formatted Word documents with native tables, vector diagrams, editable equations, and custom section layouts.

  • 📐 Authentic Word Elements: Converts Markdown directly into native Microsoft Word OpenXML elements (docx.Table, docx.Math, docx.ImageRun, outline numbering).
  • 🧩 Pluggable Core & Rich Plugin Suite: Fully extensible Unified/MDAST architecture. Use the all-in-one package, cherry-pick official @m2d/* plugins, or author custom plugins for bespoke syntax.
  • 🌐 Isomorphic Runtimes: Zero-server client-side generation (Blob) in browsers, or high-throughput batch generation (Buffer) in Node.js.
  • 🛡️ Resilient by Default: Graceful fallbacks for failed diagrams, self-healing syntax auto-repair, and protection against runaway markdown syntax.

📦 Monorepo Packages

Package Version Description
@m2d/md2docx npm All-in-one batteries-included Markdown to DOCX converter for browser & client applications.
mdast2docx npm Umbrella bundle containing @m2d/core and all official plugins.
@m2d/core npm Core conversion engine, plugin pipeline, and caching layer.
@m2d/cli npm Universal CLI binary for converting Markdown to DOCX on Node.js.
@m2d/table npm Rich tables with borders, cell fills, alignments, and repeating headers.
@m2d/list npm Multi-level outline numbering (1.1.1) and nested bullet glyphs.
@m2d/math npm LaTeX math formulas rendered as native editable Word MathML equations.
@m2d/mermaid npm Browser Mermaid diagrams with auto-healing syntax repair.
@m2d/mermaid-node npm Server-side Mermaid rendering with zero browser/DOM dependencies.
@m2d/image npm Browser image and SVG rasterization with persistent caching.
@m2d/image-node npm Server-side image and SVG rasterizer powered by sharp.
@m2d/html npm Embedded HTML tag parsing and inline CSS styling to MDAST (browser DOM).
@m2d/html-node npm Server-side DOM-less HTML parsing powered by linkedom.
@m2d/remark-docx npm Official Unified / Remark compiler plugin for direct DOCX output.
@m2d/remark-docx-node npm Server-side Remark compiler plugin with native image & diagram support.
@m2d/react-markdown npm SSR-friendly React renderer with AST retention for instant DOCX export.
@m2d/cache npm High-performance in-memory and persistent caching layer.
@m2d/mdast npm Extended MDAST and HAST TypeScript type definitions.

🚀 Quick Start

$ pnpm add mdast2docx docx unified remark-parse remark-gfm remark-math
import { toDocx } from "mdast2docx";
import {
  htmlPlugin,
  imagePlugin,
  listPlugin,
  mathPlugin,
  mermaidPlugin,
  tablePlugin,
} from "mdast2docx/plugins";
import remarkGfm from "remark-gfm";
import remarkMath from "remark-math";
import remarkParse from "remark-parse";
import { unified } from "unified";

const markdown = `
# Project Report

Executive summary with **bold** text and [links](https://github.com/md2docx/md2docx).

## System Flow

\`\`\`mermaid
graph LR
  Client --> Gateway --> Database
\`\`\`

Formula: $E = mc^2$
`;

// 1. Parse markdown
const mdast = unified()
  .use(remarkParse)
  .use(remarkGfm)
  .use(remarkMath)
  .parse(markdown);

// 2. Generate Word DOCX Blob
const docxBlob = await toDocx(
  mdast,
  {},
  {
    plugins: [
      htmlPlugin(),
      mermaidPlugin(),
      imagePlugin(),
      tablePlugin(),
      listPlugin(),
      mathPlugin(),
    ],
  },
);

📖 Documentation

Visit the official documentation site: https://md2docx.js.org


License

This library is licensed under the MIT open-source license.


with 💖 by Mayank Kumar Chaudhari

Explore related projects