# Markdown to HTML

Convert Markdown to clean HTML, with tables, task lists and code blocks, as a fragment or a full page.

Converts Markdown to HTML. Standard Markdown (CommonMark) with tables, ~~strikethrough~~, task lists and fenced code blocks.

- Endpoint: `POST https://setget.net/v1/tools/markdown-to-html` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `markdown-to-html`
- Page: https://setget.net/tools/markdown-to-html

## Inputs

- `text` (required, string): The Markdown to convert.
- `document` (optional, boolean, default `false`): Wrap the result in a complete web page with a small readable style sheet, ready to save as an .html file.
- `title` (optional, string, default `""`): Title of the page when "document" is on. Defaults to the first heading.
- `heading_ids` (optional, boolean, default `false`): Give every heading an id made from its text, so links such as #my-heading work.
- `line_breaks` (optional, boolean, default `false`): Turn every single line break into a visible line break, as chat apps do.
- `allow_html` (optional, boolean, default `false`): Keep harmless HTML tags written in the Markdown, such as <sub>, <br> and <details>. Scripts, styles, frames and event handlers are always removed. When off, HTML is shown as text.

## Example 1: A heading and a paragraph

```json
{"input":{"text":"# Hello\n\nThis is **bold** and this is a [link](https://example.com)."}}
```

Result:

```json
{"html":"<h1>Hello</h1>\n<p>This is <strong>bold</strong> and this is a <a href=\"https://example.com\">link</a>.</p>\n","characters":106,"headings":1}
```

## Example 2: A task list, a table and heading ids

```json
{"input":{"text":"## To do\n\n- [x] Write\n- [ ] Review\n\n| Item | Price |\n|------|------:|\n| Tea | 3.50 |","heading_ids":true}}
```

Result:

```json
{"html":"<h2 id=\"to-do\">To do</h2>\n<ul>\n<li class=\"task\"><input type=\"checkbox\" disabled checked /> Write</li>\n<li class=\"task\"><input type=\"checkbox\" disabled /> Review</li>\n</ul>\n<table>\n<thead>\n<tr>\n<th>Item</th>\n<th style=\"text-align:right\">Price</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>Tea</td>\n<td style=\"text-align:right\">3.50</td>\n</tr>\n</tbody>\n</table>\n","characters":351,"headings":1}
```

## Example 3: HTML in the text is shown, not run

```json
{"input":{"text":"Hello <b>there</b> <script>alert(1)</script>"}}
```

Result:

```json
{"html":"<p>Hello &lt;b&gt;there&lt;/b&gt; &lt;script&gt;alert(1)&lt;/script&gt;</p>\n","characters":76,"headings":0}
```

**Which Markdown is supported?** Standard Markdown (CommonMark) with tables, ~~strikethrough~~, task lists and fenced code blocks. Footnotes, definition lists and maths are not supported.

**Is the HTML safe to put on my site?** Yes. HTML written in the Markdown is shown as text, and links that would run script are not made into links. With "allow_html" on, only a fixed list of harmless tags and attributes is kept; scripts, styles, frames, forms and event handlers are removed.

**What does "document" add?** A complete page: doctype, character set, title and a small style sheet. Without it you get only the converted content, to place inside your own page.

**Are code blocks coloured?** No. A code block marked with a language gets a class such as language-python, which colouring scripts such as highlight.js and Prism pick up. markdown-to-pdf does colour code.

**Does it load the pictures?** No. Pictures become <img> tags that point at the address you wrote. Nothing is fetched.
