Loading...
Loading...
Convert Markdown files and strings into DOCX documents using @mohtasham/md-to-docx. Use when a user needs Markdown to Word conversion, CLI-based file conversion, options-driven styling/alignment/font family, TOC/page break handling, underline/strikethrough formatting, multi-section documents with per-section headers/footers, or programmatic conversion in Node/browser code.
npx skill4agent add mohtashammurshid/md-to-docx md-to-docx.docx.docxnpx @mohtasham/md-to-docx input.md output.docx
md-to-docx input.md output.docx
md-to-docx input.md output.docx --options options.json
md-to-docx input.md output.docx -o options.json
md-to-docx --help<input.md> <output.docx>--options <options.json>-o <options.json>styletemplatesectionstextReplacements-h--helpDOCX created at: <absolute-path>import { convertMarkdownToDocx, downloadDocx } from "@mohtasham/md-to-docx";
const markdown = "# Title\n\nHello **DOCX**.";
const blob = await convertMarkdownToDocx(markdown, {
documentType: "report",
style: {
fontFamily: "Trebuchet MS",
heading1Alignment: "CENTER",
paragraphAlignment: "JUSTIFIED",
codeBlockAlignment: "LEFT",
direction: "LTR"
}
});
downloadDocx(blob, "output.docx");convertMarkdownToDocx(markdown, options?)BlobdownloadDocx(blob, filename?)options.templateoptions.sectionsconst blob = await convertMarkdownToDocx("", {
template: {
footers: {
default: { pageNumberDisplay: "currentAndTotal", alignment: "CENTER" }
}
},
sections: [
{
markdown: "# Cover Page\n\nIntroduction here.",
titlePage: true,
headers: { first: { text: "Confidential", alignment: "RIGHT" } },
pageNumbering: { start: 1, display: "none" }
},
{
markdown: "# Chapter 1\n\nBody content.",
style: { paragraphAlignment: "JUSTIFIED" },
pageNumbering: { start: 1, display: "currentAndTotal" }
}
]
});styleheadersfooterspageNumberingpagetitlePagetypestyletemplatepageNumbering.displaynonecurrentcurrentAndTotalcurrentAndSectionTotaltextReplacementsconst blob = await convertMarkdownToDocx("# Hello oldText", {
textReplacements: [
{ find: /oldText/g, replace: "newText" },
{ find: "Hello", replace: "Hi" }
]
});######++text++~~text~~fontFamilycodeBlockAlignmenttextReplacementsCOMMENT: ...[TOC]\pagebreak---| Option | Values | Default |
|---|---|---|
| | |
| same | |
| same | |
| same | |
| same | |
| any font name string | |
| | |
| | |
| number | library default |
BlobdownloadDocxpageNumbering.starttitlePage: true