md-to-word
Skill0 starsChanged 9 days agoMITView on GitHub
Convert Markdown with Mermaid diagrams and SVG illustrations to professional Word documents. Use when the user asks to convert to Word, make a docx, or export markdown as a .docx file.
- Installs packages
4 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- fabioc-aloha/Alex_ACT_Editionedited, first seen Oct 13, 2026
- ls-open/md-to-wordtheir own version, first seen Oct 13, 2026
- huangwb8/skillstheir own version, first seen Sep 6, 2026
- fabioc-aloha/alex-cognitive-architectureedited, first seen Apr 26, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 2
- fabioc-aloha/Alex_ACT_Edition★ 074% same
- fabioc-aloha/alex-cognitive-architecture★ 064% same
Wrote their own version · 2
- huangwb8/skills★ 50same name
- ls-open/md-to-word★ 17same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository66 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/bootstrap-project/resources/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- skills/bootstrap-project/resources/CLAUDE.mdCLAUDE.md
- act-tenetsSkill
- adversarial-reviewSkill
- annotate-screenshotSkill
- anti-hallucinationSkill
- ascii-chartSkill
- assess-brainSkill
- big-ideaSkill
- bootstrap-coreSkill
- bootstrap-projectSkill
- browser-toolsSkill
- chart-big-ideaSkill
- chart-interpretationSkill
- chart-vocabularySkill
- code-reviewSkill
- communication-craftSkill
- compile-brainSkill
- convertSkill
- corpus-qa-sweepSkill
- critical-thinkingSkill
- deep-reviewSkill
- doc-hygieneSkill
- docs-shellSkill
- docx-to-mdSkill
- ethical-reasoningSkill
- evaluate-before-adoptingSkill
- figure-generatorSkill
- flint-chartSkill
- flint-interactionsSkill
- flint-themeSkill
- git-workflowSkill
- html-to-mdSkill
- humanizerSkill
- install-visual-companionsSkill
- lint-clean-markdownSkill
- markdown-mermaidSkill
- markdown-sanitization-chainSkill
- md-to-emlSkill
- md-to-htmlSkill
- md-to-txtSkill
- meditationSkill
- mutation-testingSkill
- planSkill
- platform-awarenessSkill
- print-svg-style-guideSkill
- proactive-awarenessSkill
- problem-framing-auditSkill
- project-capability-authoringSkill
- project-statusSkill
- render-chartSkill
- render-verifySkill
- rich-emailSkill
- risk-analysisSkill
- security-and-hardeningSkill
- setup-dependenciesSkill
- setup-enterprise-stackSkill
- spikeSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
11 rules. 7 are common, 2 are distinctive, and 2 are very specific to this project.
7
Common
Most of the 3 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 39
Convert to Word: Run md-to-word.cjs — produces a complete, styled document
- Common: line 40
Optional polish: Add page breaks, headers/footers, custom branding
- Common: line 66
All Mermaid diagram types are supported:
- Common: line 205
Use viewBox for scalable graphics
- Common: line 207
Keep file size under 500KB for fast conversion
- Common: line 208
Avoid external references (they won't resolve)
- Very specific: line 243
When a Mermaid block has no classDef, no %%{init}%% directive, and no explicit theme variables, the converter injects a default pastel …
- Distinctive: line 288
All tables receive professional OOXML styling (tightened in v5.5.0 for denser, more reference-document-style tables):
- Common: line 314
All headings: keepNext + keepLines (no orphans)
- Common: line 321
Keep together: Won't split across pages
- Distinctive: line 498
Not earning tokens if the user must manually fix the same structural or styling issues on every conversion
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Md To Word
One command to professional Word documents — diagrams, tables, and formatting done right on first attempt.
Convert any Markdown document into polished Word (.docx) files ready for stakeholders, executives, and external audiences. Supports all standard Markdown formatting, Mermaid diagrams (auto-converted to PNG), and SVG illustrations (auto-embedded).
Why Use This?
| Without This Skill | With This Skill |
| Mermaid diagrams missing or broken | Auto-rendered to high-res PNG, optimally sized |
| SVG images not displaying | Auto-converted to PNG with proper dimensions |
| Tables plain and unprofessional | Microsoft-branded headers, borders, zebra striping |
| Tables split mid-row across pages | Smart pagination keeps rows intact |
| Images overflow page boundaries | 90% page coverage constraint ensures fit |
| Bullet lists merge into paragraphs | Preprocessor fixes spacing automatically |
| Code blocks lose formatting | Consolas font, gray background, proper borders |
| Links plain text | Blue underlined hyperlinks |
| Headings inconsistent | Branded colors, proper hierarchy |
Document Publishing Workflow
Markdown (.md) → md-to-word.cjs → Word (.docx) → Final PDF
↓ ↓ ↓ ↓
Source Automation Manual polish Distribution
(your docs) (this skill) (page breaks, (File > Save As)
headers/footers)- Convert to Word: Run
md-to-word.cjs— produces a complete, styled document - Optional polish: Add page breaks, headers/footers, custom branding
- Export PDF: Word's File > Save As > PDF gives best fidelity
Supported Markdown Formatting
| Feature | Support | Notes |
| Headings (H1-H6) | ✅ Full | Branded colors, proper spacing |
| Bold/Italic/Strikethrough | ✅ Full | **bold**, *italic*, ~~strike~~ |
| Bullet lists | ✅ Full | Nested supported |
| Numbered lists | ✅ Full | Auto-numbered |
| Task lists | ✅ Full | - [ ] / - [x] converted |
| Tables | ✅ Full | Professional styling |
| Code blocks | ✅ Full | Monospace styling preserved |
| Inline code | ✅ Full | Monospace with background |
| Links | ✅ Full | Blue underlined |
| Images (PNG/JPG) | ✅ Full | Centered, auto-sized |
| SVG images | ✅ Auto-convert | Rendered to PNG |
| Mermaid diagrams | ✅ Auto-convert | Rendered to PNG |
| Blockquotes | ✅ Full | Gray left border |
| Horizontal rules | ✅ Full | Light gray line |
| Footnotes | ✅ Pandoc | Via pandoc extension |
| YAML frontmatter | ✅ Strip | --strip-frontmatter option |
Mermaid Diagram Support
All Mermaid diagram types are supported:
| Diagram Type | Detection | Sizing Strategy |
| Flowchart LR | flowchart lr | Width priority (6.5") |
| Flowchart TB | flowchart tb | Height priority (3.6") |
| Sequence | sequenceDiagram | Width priority |
| Gantt | gantt | Width priority (wide) |
| Class | classDiagram | Auto |
| ER | erDiagram | Auto |
| State | stateDiagram | Auto |
| Pie | pie | Smaller width |
| Mindmap | mindmap | Width priority |
| Timeline | timeline | Width priority |
Diagrams are rendered at 4x scale (4800px width) for crisp printing, then sized to fit within page bounds.
Rendered PNGs are checked for chunk structure/checksums, valid dimensions, complete compressed raster data, and row filters before replacing an existing diagram. Decompressed raster data, including scanline filter bytes, is limited to 256 MiB before inflation. Split an oversized diagram or pre-render it at a smaller resolution rather than bypassing validation.
The Word document and newly generated images are staged until rendering, Pandoc, and document post-processing all succeed. A failure before publication preserves the complete prior output set, even when an earlier diagram succeeded. Handled publication errors roll back replaced files; failed rollback reports the retained recovery copies. This does not guarantee atomicity across process crashes or power loss.
Quick Start
One-Command Conversion
# From your project root
node skills/md-to-word/scripts/md-to-word.cjs docs/spec.md
# With custom output name
node skills/md-to-word/scripts/md-to-word.cjs README.md output.docx
# Keep intermediate files for debugging
node skills/md-to-word/scripts/md-to-word.cjs docs/plan.md --keep-tempWhat It Does
- Preprocesses Markdown — fixes bullet lists, checkbox syntax, spacing
- Converts Mermaid to PNG — renders diagrams with white backgrounds
- Calculates optimal sizing — reads actual PNG dimensions, fits 90% of page
- Converts SVG to PNG — handles banner images
- Generates Word via pandoc — clean markdown-to-docx conversion
- Formats tables — Microsoft blue headers, borders, alternating rows
- Centers images — all diagrams centered on page
- Styles headings — consistent colors and spacing
Installation
Prerequisites
| Tool | Purpose | Required? |
| Node.js 24+ | Script runtime | Yes |
| pandoc | Markdown to Word | Yes |
| mermaid-cli | Mermaid diagrams to PNG | Only for diagrams |
| jszip | OOXML post-processing (table formatting, image centering) | No — degrades |
| svgexport | SVG to PNG | No |
To check what is present and install what is missing:
/alex-act-one setup-dependenciesThat command owns the install instructions for every platform, so they exist in one place and cannot drift from what the scripts actually look for. Running a conversion without a required tool also prints the exact command for your platform at the moment you need it.
Options
| Option | Default | Description |
--toc | off | Generate Table of Contents. A [toc] marker in the source is stripped but does not auto-enable TOC (since v5.5.0). When the marker is found without --toc, a warning is logged so the heir can either pass --toc explicitly or remove the marker. |
--cover | off | Generate cover page from H1 + date |
--style PRESET | professional | Style preset (see below) |
--page-size SIZE | letter | Page size: letter, a4, 6x9 |
--reference-doc PATH | — | Custom Word template (.dotx) |
--images-dir DIR | images | Directory for generated PNG files |
--embed-images | off | Embed local images as base64 |
--strip-frontmatter | on | Remove YAML frontmatter |
--no-format-tables | off | Skip table styling (faster) |
--keep-temp | off | Keep temporary files for debugging |
--watch | off | Auto-rebuild on source change |
--recursive | off | Process all .md files in directory |
--dry-run | off | Validate only, no output |
--debug | off | Save preprocessed markdown |
Style Presets
| Preset | Body Font | Heading Style | Use Case |
| professional | Aptos 11pt | Aptos Display, navy and teal hierarchy | Business documents, specs, reports |
| academic | Times New Roman 12pt | Black, double-spaced | Dissertations, papers, theses |
| course | Calibri 11pt | Virginia Tech burgundy | Course materials, syllabi |
| creative | Georgia 11pt | Slate blue | Blog posts, narratives |
# Academic paper with TOC
node md-to-word.cjs thesis.md --style academic --toc
# Professional report with cover
node md-to-word.cjs quarterly-report.md --style professional --cover --tocSVG Image Handling
SVG files are automatically detected and converted to PNG for Word compatibility:
<!-- This SVG reference in your Markdown... -->

<!-- ...becomes this embedded PNG in Word -->
{width=5.8in}Requirements: svgexport — run /alex-act-one setup-dependencies to check and install
Best practices for SVG sources:
- Use viewBox for scalable graphics
- Embed fonts or use web-safe font stack
- Keep file size under 500KB for fast conversion
- Avoid external references (they won't resolve)
Image Sizing Algorithm
The script automatically fits images to page bounds. The constraints are codified
in md-to-word.cjs:
Page: 8.5" × 11" (Letter)
Margins: 1" each side
Usable area: 6.5" × 9.0"
MAX_IMAGE_WIDTH_RATIO = 0.90 → max width ≈ 5.85"
MAX_IMAGE_HEIGHT_RATIO = 0.60 → max height ≈ 5.40"These ratios apply width-priority for landscape/wide diagrams (LR flowcharts, gantts, sequence diagrams) and height-priority for portrait/tall diagrams (TB/TD flowcharts with multiple subgraphs). The algorithm picks the more restrictive constraint so the image fits in both dimensions.
Algorithm Steps
- Read PNG dimensions from file header (pure Node.js, no dependencies)
- Calculate scale factors for width and height constraints
- Apply most restrictive — ensures fit in both dimensions
- Specify constraining dimension — pandoc preserves aspect ratio
Mermaid Palette and Fidelity
When a Mermaid block has no classDef, no %%{init}%% directive, and no
explicit theme variables, the converter injects a default pastel palette
(GitHub-style soft colors with dark text) before rendering. This gives WYSIWYG
fidelity to authors who don't styled-by-design every diagram.
Why per-diagram-type injection matters
| Diagram type | Honors classDef? | Color path |
flowchart / graph | Yes | classDef (preferred) or injected init |
classDiagram | Partial | classDef or injected init |
sequenceDiagram | No | themeVariables only (e.g. actorBkg, noteBkgColor) |
stateDiagram-v2 | No | themeVariables only (primaryColor, mainBkg, labelBoxBkgColor) |
erDiagram | No | themeVariables only |
Without diagram-type-aware injection, sequence and state diagrams would render
as flat neutral nodes regardless of any classDef the author wrote.
Behavior
flowchart/graph/classDiagramwithclassDef→ respected, no injection (author wins)flowchart/graphwithoutclassDef→ palette injected + lint nudgesequenceDiagram/stateDiagram-v2without%%{init}%%or explicitactorBkg/primaryColor→ palette injected (only path to colors)- Any block with
%%{init}%%already present → respected, no injection
Opting out
Pass --no-default-palette to disable injection. Diagrams without classDef or
explicit theme will then render with mermaid's default neutral theme, and a
warning is emitted per affected diagram.
Lint warnings
During preprocessing the converter emits 💡 nudges for unstyled flowcharts
("inject default pastel palette") and ⚠️ warnings when --no-default-palette
is set on diagrams that would have rendered flat.
Table Formatting
All tables receive professional OOXML styling (tightened in v5.5.0 for denser, more reference-document-style tables):
| Element | Style |
| Header row | Microsoft blue (#0078D4), white text, bold 9pt |
| Even data rows | Light gray (#F0F0F0) |
| Odd data rows | White (#FFFFFF) |
| Data cell font | 8.5pt black |
| Borders | Gray outer (#666666), light inner (#AAAAAA) |
| Cell padding | 1pt top/bottom, 3pt left/right |
| Pagination | cantSplit + keepWithNext (no orphan headers) |
| Repeat headers | Header row repeats on each page for long tables |
Professional Features
Page Numbers
Centered page numbers in the footer, gray text (9pt).
Heading Hierarchy
- H1: Aptos Display 24pt, navy, bold, 360/120 twip spacing
- H2: Aptos Display 16pt, teal, bold, 280/120 twip spacing
- H3: Aptos Display 14pt, blue, bold, 240/80 twip spacing
- All headings: keepNext + keepLines (no orphans)
Code Blocks
- Font: Consolas 9pt
- Background: Light gray (#F5F5F5)
- Border: Left accent bar (#CCCCCC)
- Keep together: Won't split across pages
Hyperlinks
- Color: Microsoft blue (#0563C1)
- Style: Single underline
- Applied to both inline links and reference links
Captions
Paragraphs starting with "Table N" or "Figure N":
- Centered, italic, 9pt gray
- keepNext binding to following content
Troubleshooting
| Issue | Cause | Fix |
| "mmdc not found" | mermaid-cli not installed | Run /alex-act-one setup-dependencies |
| "pandoc not found" | pandoc not in PATH | Run /alex-act-one setup-dependencies, then restart the terminal |
| "svgexport not found" | svgexport not installed | Run /alex-act-one setup-dependencies |
| Tables not styled | jszip not available | Use the unified setup helper or select the matching private runtime with ALEX_ACT_ONE_RUNTIME_ROOT |
| Diagrams too small | Outdated script | Update to v5.3.0+ |
| Images overflow | Complex diagram | Use --debug and check PNG dimensions |
| SVG not converting | Missing svgexport | Install or use PNG source |
| Document corrupt | Incomplete write | Check disk space, re-run |
Debug Mode
node md-to-word.cjs doc.md --debug --keep-temp
# Check _debug_combined.md for preprocessed content
# Check images/ folder for generated PNGsmacOS Fallback (No Pandoc)
macOS ships textutil which can convert HTML to DOCX natively:
# Convert markdown to HTML first, then HTML to DOCX
npx marked document.md -o document.html
textutil -convert docx document.html -output document.docx| Feature | Pandoc (primary) | textutil (fallback) |
| Table styling | Full (via jszip post-processing) | Basic |
| Mermaid diagrams | Supported (pre-rendered PNG) | Must be pre-rendered |
| Heading styles | Mapped to Word styles | Basic HTML mapping |
| Cross-references | Supported | Not supported |
| Install | brew install pandoc | Built-in (macOS only) |
Limitations: textutil needs HTML input (not raw Markdown), produces simpler formatting, and doesn't support the table styling or image sizing that md-to-word.cjs provides. Use only when Pandoc is unavailable and a quick conversion is needed.
Batch Processing
Convert a Folder
# Windows PowerShell
Get-ChildItem docs/*.md | ForEach-Object {
node skills/md-to-word/scripts/md-to-word.cjs $_.FullName --style professional
}# macOS/Linux
for f in docs/*.md; do
node skills/md-to-word/scripts/md-to-word.cjs "$f" --style professional
doneRecursive Directory
# All .md files in docs/ and subdirectories
node skills/md-to-word/scripts/md-to-word.cjs docs --recursive --style professionalWatch Mode
# Auto-rebuild when source changes
node skills/md-to-word/scripts/md-to-word.cjs spec.md --watchIntegration Examples
GitHub Actions CI/CD
Pandoc must already be provisioned on the runner. Resolve optional npm tool versions from this checkout's shared registry rather than copying old pins:
<!-- dependency-pin-example:start -->const d = require('./scripts/shared/dependencies.cjs');
console.log(JSON.stringify(['mmdc', 'svgexport'].map(key => d.specOf(d.TOOLS[key]))));<!-- dependency-pin-example:end --># Generate Word docs as build artifacts
- name: Generate Word Documents
shell: pwsh
run: |
$specs = node -e "const d = require('./scripts/shared/dependencies.cjs'); console.log(JSON.stringify(['mmdc', 'svgexport'].map(key => d.specOf(d.TOOLS[key]))));" | ConvertFrom-Json
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
npm install --global @specs
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
node skills/md-to-word/scripts/md-to-word.cjs docs/spec.md --toc --cover
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: word-documents
path: docs/*.docxnpm Script
{
"scripts": {
"docs:word": "node skills/md-to-word/scripts/md-to-word.cjs docs/README.md --style professional --toc"
}
}For Other Projects
- Copy
skills/md-to-word/scripts/md-to-word.cjsto the same relative path in the target project. - Copy the complete
scripts/shared/directory to the same relative path in the target project. Keep its helpers together, includingprocess-command.cjsandruntime-status.cjs, so unconditional and transitive imports resolve. - Install prerequisites: Pandoc is required; jszip, Mermaid CLI, and svgexport are optional format helpers. The copied
tool-runnerstill prints the install command for any missing tool. - Run:
node skills/md-to-word/scripts/md-to-word.cjs your-doc.md.
Version History and Acceptance Criteria
Full version history and the conversion acceptance decision table moved to
references/version-history-and-acceptance.md
to keep this file under the Agent Skills recommended body length.
Related Skills
| Skill | Relationship |
| markdown-mermaid | Mermaid syntax and ATACCU compliance |
| lint-clean-markdown | Pre-flight the source — pass clean Markdown in |
| markdown-sanitization-chain | Sanitize user-supplied Markdown before conversion |
| markdown-mermaid § Mode Fragility | Why we default to flowchart mode |
| md-to-html | HTML output with same preprocessing |
Falsifiability
- This skill is wrong if .docx files produced per its guidance fail to open or lose formatting on round-trip (Word → save → reopen)
- The reference-doc approach is stale if Pandoc changes how --reference-doc applies styles in a major version
- Not earning tokens if the user must manually fix the same structural or styling issues on every conversion
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

