Toolpal

@toolpal/markdown-to-doc

public

v2.0published 1 download this weekMIT

Converts Markdown (inline or .md/.txt file) or structured JSON/sheets locally into a formatted Word (.docx), PDF (.pdf), or Excel (.xlsx) file. Supports headings, bold/italic/code, links, lists, code blocks, blockquotes, and tables. Offline, no API key needed.

README.md1.6 KBRaw
# @toolpal/markdown-to-doc

Turns Markdown (inline or from a `.md` file) or structured JSON into polished **Word (`.docx`)**, **PDF (`.pdf`)**, or **Excel (`.xlsx`)** files locally — 100% offline, with no API keys and zero external dependencies.

## How it works

- **Word (`.docx`):** Preserves headings (`#`–`####`), **bold**, *italic*, `` `inline code` ``, clickable links, bullet and numbered lists, shaded monospace code blocks, blockquotes, horizontal rules, and Markdown tables.
- **PDF (`.pdf`):** Renders a multi-page vector PDF (Letter or A4) with wrapped typography, headings, shaded code blocks, bordered tables, blockquotes, lists, and `Page X of Y` footers.
- **Excel (`.xlsx`):** Converts Markdown pipe tables into individual named worksheets (named from the preceding heading), or converts structured `sheets` / JSON arrays directly into typed multi-sheet workbooks with bold frozen headers and auto-sized columns.

## Examples

### Markdown to Word or PDF

```json
{
  "format": "pdf",
  "title": "Q4 Launch Plan",
  "subtitle": "Prepared Nov 2026",
  "markdown": "## Milestones\n\n| Phase | Target | Owner |\n|---|---|---|\n| Beta | Nov 25 | Engineering |\n| GA | Dec 10 | Product |"
}
```

### Structured JSON to Excel

```json
{
  "format": "xlsx",
  "filename": "pricing-tiers",
  "sheets": [
    {
      "name": "Plans",
      "columns": ["Plan", "Monthly USD", "Seats"],
      "rows": [
        ["Starter", 29, 3],
        ["Team", 99, 15]
      ]
    }
  ]
}
```

## Notes

- Runs 100% offline (`net: false`, zero environment variables).
- Supports Letter (`letter`, default) and A4 (`a4`) page sizes for `.docx` and `.pdf`.