Version 0.1.1
Overview
Updated 22 Oct 2026
@m2d/cli (alias: @m2d/md2docx-node): Command-line tool and programmatic Node.js engine for Markdown to DOCX conversion with native image and Mermaid diagram rasterization.
✨ Features
- 💻 CLI Tool: Convert Markdown files to styled
.docxdocuments directly from your terminal or CI/CD pipelines. - 🚀 Programmatic Node.js API: Exported
md2docxfunction pre-wired with@m2d/remark-docx-nodefor server rendering. - 🖼️ Native Image Resolution: Automatically resolves local file paths, HTTPS URLs, and Base64 data URIs via
sharp. - 📊 Headless Mermaid Diagrams: Compiles flowcharts, sequence diagrams, and architecture diagrams into Word DrawingML pictures.
💡 Looking for client-side / browser compilation? Use @m2d/md2docx or @m2d/remark-docx.
📦 Installation
Global CLI
# with pnpm
$ pnpm add -g @m2d/cli
# or npm
$ npm install -g @m2d/cliLocal Project Dependency
$ pnpm add @m2d/cli🚀 CLI Usage
Convert a Markdown file to Word:
# Using npx
$ npx @m2d/cli README.md -o document.docx
# Using alias binary
$ md2docx README.md -o document.docx
$ md2docx-node README.md -o document.docxOptions
Usage:
$ md2docx <input.md> [options]
Arguments:
<input.md> Path to Markdown file to convert
Options:
-o, --output <file> Output DOCX file path (default: <input>.docx)
-t, --title <title> Document title
-a, --author <author> Document author
-d, --description <desc> Document description
-c, --config <file> Use custom configuration file
-i, --init [file] Create default config file
-h, --help Show this help message
-v, --version Show version number⚡ Programmatic Node.js Usage
import { md2docx } from "@m2d/cli";
import fs from "node:fs/promises";
const markdown = `
# Backend Document 🚀
- Automatically resolves images
- Automatically renders Mermaid charts
\`\`\`mermaid
graph TD
A[Input Markdown] --> B[DOCX Buffer]
\`\`\`
`;
const buffer = await md2docx(markdown, { title: "Automated Report" });
await fs.writeFile("report.docx", buffer);License
This library is licensed under the MIT open-source license.
with 💖 by Mayank Kumar Chaudhari