# markdown-formatter [Health: Active]

**Category:** 🏢 Workplace & Productivity  
**Repository:** https://github.com/XJTLUmedia/AI_answer_copier  
**GitHub Stars:** 4  
**npm Downloads (last month):** 356  
**Views:** 8  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/markdown-formatter

## Description
MCP Server for Markdown conversion to HTML, PDF, DOCX, LaTeX, CSV, JSON, XML, XLSX, RTF, PNG

## Tools
Capabilities this server exposes over MCP:

- **harmonize_markdown** — Standardize and normalize Markdown syntax without changing the document's meaning. Re-formats headers (ATX-style), normalizes list markers to '-', enforces fenced code blocks with backticks, and applies consistent indentation. Side effects: when output_path is provided, writes the harmonized Markdown to disk (creates parent directories as needed, overwrites existing files). When output_path is omitted, returns the harmonized text as a string with no file I/O. Returns: harmonized Markdown string (if no output_path), or JSON with { success, file_path, file_size_bytes, format } (if output_path set). Use this tool when you need to clean up inconsistent Markdown formatting before further processing. Prefer convert_to_md with harmonize=true if you also need to save the result, as it combines both steps. Not suitable for converting Markdown to other formats — use the convert_to_* tools instead.
- **convert_to_txt** — Convert Markdown to plain text by stripping all formatting — removes headers, bold/italic markers, links, images, code fences, and HTML tags. The result is a human-readable plain-text string with no markup. This is a destructive conversion: formatting information is permanently lost. Side effects: when output_path is provided, writes the plain text to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns the plain text string directly. Returns: plain text string (if no output_path), or JSON { success, file_path, file_size_bytes, format } (if output_path set). Use this instead of convert_to_md when you need formatting-free content (e.g. for indexing, search, or clipboard). Use convert_to_html or convert_to_pdf if you need to preserve the document's visual structure.
- **convert_to_rtf** — Convert Markdown to Rich Text Format (RTF). Produces an RTF document string preserving basic formatting: bold, italic, headers (as styled paragraphs), lists, and code blocks. Side effects: when output_path is provided, writes the RTF file to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns the raw RTF markup as a string. Returns: RTF markup string (if no output_path), or JSON { success, file_path, file_size_bytes, format } (if output_path set). Use this when the target application requires RTF (e.g. legacy word processors, email clients). Prefer convert_to_docx for modern Word documents, or convert_to_html for web display.
- **convert_to_latex** — Convert Markdown to LaTeX source code. Produces a LaTeX document fragment with \section, \textbf, \textit, \begin{itemize}/\begin{enumerate} list environments, verbatim code blocks, and table environments. KaTeX math expressions in the Markdown are passed through as native LaTeX math. Side effects: when output_path is provided, writes the .tex file to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns the LaTeX source as a string. Returns: LaTeX source string (if no output_path), or JSON { success, file_path, file_size_bytes, format } (if output_path set). Use this when you need to embed content in a LaTeX workflow or compile to PDF via pdflatex/xelatex externally. For direct PDF output without a LaTeX toolchain, use convert_to_pdf instead.
- **convert_to_docx** — Convert Markdown to a Microsoft Word DOCX file. Produces a binary .docx document with styled headings, bold/italic text, numbered and bulleted lists, and code formatting. This is a binary format — output_path should almost always be provided. Side effects: when output_path is provided, writes the DOCX binary to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns a JSON object with { format: 'docx', file_size_bytes, hint, base64_preview } — the hint will tell you to re-call with output_path to save the file. Returns: JSON write-confirmation (if output_path set), or JSON binary-guidance object (if omitted). Use this for Word-compatible documents. Prefer convert_to_rtf for legacy word processors, convert_to_pdf for read-only distribution, or convert_to_html for web.
- **convert_to_pdf** — Convert Markdown to a PDF document. Renders the Markdown as styled HTML (GFM tables, KaTeX math) and then prints it to PDF via a headless Chromium browser (Puppeteer). Requires a locally installed Chrome, Edge, or Chromium — set PUPPETEER_EXECUTABLE_PATH env var to override auto-detection. This is a binary format — output_path should almost always be provided. Side effects: launches a transient headless browser process for rendering (no network requests are made for the conversion itself, though the HTML references a CDN KaTeX stylesheet which may be fetched). When output_path is provided, writes the PDF to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns JSON { format: 'pdf', file_size_bytes, hint, base64_preview }. Returns: JSON write-confirmation (if output_path set), or JSON binary-guidance object (if omitted). Use this for high-fidelity, print-ready document output. Prefer convert_to_html for web-viewable output, convert_to_docx for editable documents, or convert_to_latex for LaTeX toolchains.
- **convert_to_image** — Convert Markdown to a PNG image. Renders the Markdown as styled HTML (GFM tables, KaTeX math) and takes a full-page screenshot via a headless Chromium browser (Puppeteer). Requires a locally installed Chrome, Edge, or Chromium — set PUPPETEER_EXECUTABLE_PATH env var to override auto-detection. This is a binary format — output_path should almost always be provided. Side effects: launches a transient headless browser process (no persistent state; may fetch KaTeX CDN stylesheet). When output_path is provided, writes the PNG to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns JSON { format: 'png', file_size_bytes, hint, base64_preview }. Returns: JSON write-confirmation (if output_path set), or JSON binary-guidance object (if omitted). Use this when you need a visual snapshot of the rendered Markdown (e.g. for embedding in chat, previews, social cards). Prefer convert_to_pdf for paginated print output, or convert_to_html for interactive web content.
- **convert_to_csv** — Extract tables from Markdown and convert them to CSV format. Parses GFM pipe-tables from the input and outputs comma-separated values. If the Markdown contains multiple tables, they are concatenated with a blank line separator. Non-table content is ignored. If the Markdown contains no tables, returns an empty string. Side effects: when output_path is provided, writes the CSV to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns the CSV text directly as a string. Returns: CSV text string (if no output_path), or JSON { success, file_path, file_size_bytes, format } (if output_path set). Use this for lightweight tabular export or when downstream tools expect CSV. Prefer convert_to_xlsx for Excel-compatible spreadsheets with multiple sheets, or convert_to_json for structured data.
- **convert_to_json** — Convert Markdown to a structured JSON representation. Parses the document into a JSON object with the document title as the root key, containing arrays of section objects with headings, paragraphs, lists, code blocks, and tables. Useful for programmatic analysis or feeding structured content into other systems. Side effects: when output_path is provided, writes the JSON to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns the JSON string directly. Returns: JSON string (if no output_path), or JSON { success, file_path, file_size_bytes, format } (if output_path set). Use this when you need a machine-readable AST-like representation of the Markdown content. Prefer convert_to_xml for XML-based interchange, or convert_to_csv/convert_to_xlsx for tabular data extraction.
- **convert_to_xml** — Convert Markdown to an XML document. Parses the Markdown into a structured XML tree with a root element named after the title parameter, containing <section>, <heading>, <paragraph>, <list>, <code>, and <table> elements. Produces well-formed XML with an <?xml?> declaration. Side effects: when output_path is provided, writes the XML to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns the XML string directly. Returns: XML string (if no output_path), or JSON { success, file_path, file_size_bytes, format } (if output_path set). Use this for XML-based data interchange or when downstream systems require XML input. Prefer convert_to_json for JSON APIs, convert_to_html for XHTML/web content, or convert_to_csv for flat tabular data.
- **convert_to_xlsx** — Convert Markdown tables to a Microsoft Excel XLSX spreadsheet. Parses GFM pipe-tables from the input and creates an Excel workbook. Each table becomes a sheet in the workbook. Non-table content is ignored. If the Markdown contains no tables, produces an empty workbook. This is a binary format — output_path should almost always be provided. Side effects: when output_path is provided, writes the XLSX binary to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns JSON { format: 'xlsx', file_size_bytes, hint, base64_preview }. Returns: JSON write-confirmation (if output_path set), or JSON binary-guidance object (if omitted). Use this when you need a full Excel file with formatting. Prefer convert_to_csv for lightweight plain-text tabular export, or convert_to_json for structured programmatic access.
- **convert_to_html** — Convert Markdown to a complete, styled HTML document. Renders GFM (tables, task lists, strikethrough) and KaTeX math into semantic HTML with an embedded stylesheet for clean presentation. The output is a full <!DOCTYPE html> document with <head> (charset, KaTeX CSS CDN link, inline styles) and <body>. Side effects: when output_path is provided, writes the HTML file to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns the full HTML string directly. Returns: HTML document string (if no output_path), or JSON { success, file_path, file_size_bytes, format } (if output_path set). Use this when you need a file saved to disk or when you need the full document. Prefer generate_html if you only need the HTML string returned directly (no file I/O) and want inline styles without a CDN link. Prefer convert_to_pdf for print-ready output, or convert_to_image for a visual snapshot.
- **convert_to_md** — Export Markdown content, optionally harmonizing its formatting first. When harmonize=false (default), returns the input Markdown unchanged. When harmonize=true, applies the same normalization as harmonize_markdown (ATX-style headers, '-' list markers, fenced code blocks, consistent indentation) before returning. Side effects: when output_path is provided, writes the Markdown to disk (creates parent directories, overwrites existing files). When output_path is omitted, returns the Markdown string directly. Returns: Markdown string (if no output_path), or JSON { success, file_path, file_size_bytes, format } (if output_path set). Use this when you want to save Markdown to a file (with or without cleanup). Prefer harmonize_markdown if you only want to normalize formatting without saving to disk. Use the convert_to_* family for other output formats.
- **generate_html** — Generate a complete, self-contained HTML document from Markdown with all styles inlined. Renders GFM (tables, task lists, strikethrough) and KaTeX math into a full HTML page with an embedded <style> block and a KaTeX CSS CDN link. Returns the HTML string directly — no file is written to disk. Side effects: none. This tool is read-only and performs no file I/O. Returns: a complete HTML document string (<!DOCTYPE html>…</html>) with inline styles, ready for rendering in a browser. The optional title parameter sets the <title> tag in the HTML <head> section. Use this when you need styled HTML output returned as a string (e.g., for embedding in responses or previewing). Prefer convert_to_html when you need to write the HTML to a file on disk. Prefer convert_to_pdf or convert_to_image for non-HTML visual output formats.
- **convert_to_slack** — Convert Markdown to Slack mrkdwn format. Transforms bold (**) to single asterisks, italic to underscores, links to Slack <url|text> syntax, and headers to bold text. Use this when pasting formatted content into Slack messages.
- **convert_to_discord** — Convert Markdown to Discord-compatible format. Transforms headers to styled bold/underline text that renders correctly in Discord messages. Code blocks and basic formatting are preserved.
- **convert_to_jira** — Convert Markdown to JIRA wiki markup. Transforms headers to h1./h2., bold to single asterisks, code blocks to {code} blocks, links to [text|url], and lists to JIRA * and # syntax.
- **convert_to_confluence** — Convert Markdown to Confluence wiki markup. Similar to JIRA but includes Confluence-specific {info}, {note} panels and {code:language=x} syntax.
- **convert_to_asciidoc** — Convert Markdown to AsciiDoc format. Transforms headers to = syntax, code blocks to ---- delimited blocks, links to url[text] syntax, and images to image::url[alt] directives.
- **convert_to_rst** — Convert Markdown to reStructuredText (RST) format. Transforms headers to underlined text, code blocks to .. code-block:: directives, and links to RST reference syntax.
- **convert_to_mediawiki** — Convert Markdown to MediaWiki markup. Transforms headers to == syntax, bold to triple quotes, code to <syntaxhighlight> tags, and tables to {| wikitable format.
- **convert_to_bbcode** — Convert Markdown to BBCode format. Transforms formatting to [b], [i], [s], [code], [url], [img] tags. Used for forum posts on phpBB, vBulletin, and similar platforms.
- **convert_to_textile** — Convert Markdown to Textile markup format. Used by Redmine, older versions of Basecamp, and some CMS platforms.
- **convert_to_orgmode** — Convert Markdown to Emacs Org Mode format. Transforms headers to * syntax, bold to *text*, code blocks to #+BEGIN_SRC/#+END_SRC, and links to [[url][text]] syntax.
- **convert_to_email_html** — Convert Markdown to email-optimized HTML with all styles inlined. Produces HTML compatible with Outlook, Gmail, Apple Mail, and other email clients. No external CSS dependencies. Wraps content in a responsive email table layout.
- **html_to_markdown** — Convert HTML to Markdown. Performs round-trip import of HTML content back to Markdown format. Handles headings, tables, lists, code blocks, links, images, and inline formatting. Useful for importing web content or converting HTML emails to Markdown.
- **repair_markdown** — Repair broken Markdown from LLM output or copy-paste. Fixes unclosed code fences, broken tables (mismatched columns, missing separators), stray emphasis markers, missing heading spaces, inconsistent list indentation, broken links, and excessive whitespace.
- **lint_markdown** — Lint Markdown and report issues. Returns a JSON array of lint issues found in the document, each with line number, column, severity (error/warning/info), rule name, message, and fixable flag. Checks for: missing heading spaces, trailing whitespace, inconsistent list markers, hard tabs, multiple blank lines, bare URLs, unclosed emphasis, and unclosed code fences.
- **extract_code_blocks** — Extract all code blocks from a Markdown document. Returns a JSON array of code blocks, each with language, code content, and start/end line numbers. Useful for extracting code snippets from LLM responses or documentation.
- **extract_links** — Extract all links and images from a Markdown document. Returns a JSON array with link text, URL, line number, and type (inline, reference, image, autolink). Useful for link checking, SEO analysis, or extracting references.
- **generate_toc** — Generate a Table of Contents from Markdown headings. Returns a Markdown-formatted TOC with indented links to each heading. Handles duplicate heading slugs. The max_depth parameter controls the deepest heading level to include.
- **analyze_document** — Analyze a Markdown document and return comprehensive statistics. Returns JSON with: line/word/character/paragraph/sentence counts, heading/code block/table/link/image/list/blockquote counts, and estimated reading time in minutes.
- **extract_structure** — Extract the full structure of a Markdown document. Returns JSON with document statistics, heading outline, code block summary (language, line count, positions), and link summary (totals by type, unique URL count). Provides a bird's-eye view of document architecture.
- **batch_convert** — Batch convert multiple markdown documents to multiple output formats in a single call. Supports all conversion formats: txt, csv, json, xml, xlsx, latex, rtf, docx, pdf, html, md, email_html, slack, discord, jira, confluence, asciidoc, rst, mediawiki, bbcode, textile, orgmode. Each item in the batch is processed independently — one failure does not stop the rest. Results include per-item success/error status. When output_dir is provided, files are saved to disk in subdirectories per input document. Without output_dir, text format results are returned inline; binary formats return base64.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "markdown-formatter": {
    "command": "npx",
    "args": ["-y","@xjtlumedia/markdown-mcp-server"]
  }
}
```

## Documentation

## What the markdown-formatter MCP server does

The markdown-formatter MCP server exposes document conversion, Markdown cleanup, inspection, and batch-processing operations through MCP. It is designed for workflows where Markdown produced by an AI or copied from another source must become a file, a platform-specific message, or structured data.

Supported document outputs include plain text, HTML, PDF, DOCX, LaTeX, RTF, CSV, JSON, XML, XLSX, PNG, and Markdown. HTML output can include GitHub-Flavored Markdown tables and KaTeX math. PDF and image conversion use headless Chromium, while DOCX output preserves common document structures such as headings, lists, and code formatting. Markdown tables can be exported to CSV, or placed into separate XLSX sheets.

Platform converters target Slack, Discord, JIRA, Confluence, AsciiDoc, reStructuredText, MediaWiki, BBCode, Textile, and Emacs Org Mode. An HTML import tool converts a complete document or fragment back to Markdown.

## How it works

An MCP client calls an individual tool with Markdown or HTML input and conversion options where supported. The server includes tools for normalizing Markdown, repairing common syntax damage, and reporting lint findings as structured JSON. Repair targets include unclosed fences, malformed tables, stray emphasis markers, missing spaces after headings, and broken links.

Analysis tools return code blocks, links and images, heading-based tables of contents, document counts, estimated reading time, and an overall structural summary. The `batch_convert` tool accepts multiple documents and multiple target formats in one request. Errors are isolated for each document-format combination, and an optional output directory can be used for file output.

Six built-in prompts combine these operations for common sequences: general conversion, table extraction, PDF and HTML preparation, lint-repair-lint workflows, platform conversion, and document overviews. Two resources expose a supported-format list and a format-selection guide.

## Setup and configuration

The documented quick-start method runs the package with npx:

```json
{
  "mcpServers": {
    "ai-answer-copier": {
      "command": "npx",
      "args": ["-y", "@xjtlumedia/markdown-mcp-server"]
    }
  }
}
```

The package can also be installed globally with npm, after which the `markdown-mcp-server` command is used in the MCP client configuration. The project provides an online web version, but the MCP setup described here uses the npm package. No API key or other credential is specified in the provided setup instructions.

## Tools and capabilities

The 34 listed tools cover five main areas:

- Conversion to files or strings, including HTML, PDF, DOCX, LaTeX, RTF, CSV, JSON, XML, XLSX, PNG, TXT, and Markdown.
- Conversion to collaboration, documentation, forum, and markup formats.
- Import from HTML into Markdown.
- Markdown repair, linting, code and link extraction, table-of-contents generation, and document analysis.
- Multi-document, multi-format batch conversion.

The server also provides `generate_html` for self-contained HTML returned without file I/O and `convert_to_email_html` for HTML with inlined styles intended for common email clients.

## Limitations and notes

PDF and PNG generation depend on headless Chromium according to the tool descriptions. Platform output is adapted to each target syntax; it is not necessarily interchangeable with standard Markdown. The documentation lists both 22-format batch conversion language and a broader set of individual tools, so the exact format count depends on whether platform and import capabilities are included.

_Full upstream README: https://allmcps.com/mcp/markdown-formatter/readme_

