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.

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

{
  "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

{
  "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.

Input

Validated before the workflow runs.

  • filefile

    Input .md, .txt, or .json file (alternative to inline markdown/sheets)

  • titlestring

    Document title (docx/pdf)

    max length 200

  • formatrequired"docx" | "pdf" | "xlsx"

    Target output format: docx, pdf, or xlsx

  • sheetsobject[]

    Structured worksheet data (ideal for format: xlsx, also renders as tables in docx/pdf)

    min items 1 · max items 20

  • filenamestring

    Output filename without extension

    max length 80

  • markdownstring

    Markdown text to render

    max length 500000

  • pageSize"letter" | "a4"

    Page size for docx/pdf; letter by default

  • subtitlestring

    Subtitle, author, or date line (docx/pdf)

    max length 300

JSON Schema
{
  "type": "object",
  "required": [
    "format"
  ],
  "properties": {
    "file": {
      "type": "string",
      "description": "Input .md, .txt, or .json file (alternative to inline markdown/sheets)",
      "x-toolpal-file": true
    },
    "title": {
      "type": "string",
      "maxLength": 200,
      "description": "Document title (docx/pdf)"
    },
    "format": {
      "anyOf": [
        {
          "type": "string",
          "const": "docx"
        },
        {
          "type": "string",
          "const": "pdf"
        },
        {
          "type": "string",
          "const": "xlsx"
        }
      ],
      "description": "Target output format: docx, pdf, or xlsx"
    },
    "sheets": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "name",
          "rows"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 60,
            "minLength": 1
          },
          "rows": {
            "type": "array",
            "items": {
              "anyOf": [
                {
                  "type": "array",
                  "items": {}
                },
                {
                  "type": "object",
                  "patternProperties": {
                    "^.*$": {}
                  }
                }
              ]
            },
            "maxItems": 50000
          },
          "columns": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 100
          }
        }
      },
      "maxItems": 20,
      "minItems": 1,
      "description": "Structured worksheet data (ideal for format: xlsx, also renders as tables in docx/pdf)"
    },
    "filename": {
      "type": "string",
      "maxLength": 80,
      "description": "Output filename without extension"
    },
    "markdown": {
      "type": "string",
      "maxLength": 500000,
      "description": "Markdown text to render"
    },
    "pageSize": {
      "anyOf": [
        {
          "type": "string",
          "const": "letter"
        },
        {
          "type": "string",
          "const": "a4"
        }
      ],
      "description": "Page size for docx/pdf; letter by default"
    },
    "subtitle": {
      "type": "string",
      "maxLength": 300,
      "description": "Subtitle, author, or date line (docx/pdf)"
    }
  }
}

Output

Validated before your agent receives it.

  • filerequiredfile

    Generated .docx, .pdf, or .xlsx file

  • bytesrequiredinteger
  • pagesinteger

    Page count (for PDF output)

  • blocksinteger

    Parsed block count (for DOCX/PDF output)

  • formatrequiredstring
  • sheetsinteger

    Worksheet count (for XLSX output)

JSON Schema
{
  "type": "object",
  "required": [
    "file",
    "format",
    "bytes"
  ],
  "properties": {
    "file": {
      "type": "string",
      "description": "Generated .docx, .pdf, or .xlsx file",
      "x-toolpal-file": true
    },
    "bytes": {
      "type": "integer"
    },
    "pages": {
      "type": "integer",
      "description": "Page count (for PDF output)"
    },
    "blocks": {
      "type": "integer",
      "description": "Parsed block count (for DOCX/PDF output)"
    },
    "format": {
      "type": "string"
    },
    "sheets": {
      "type": "integer",
      "description": "Worksheet count (for XLSX output)"
    }
  }
}