API & MCP
Everything a person can do on Safe Markdown Preview, a program or AI agent can do with the same inputs and get the identical result.
HTTP API
POST https://safemarkdownpreview.usefulweb.site/api/v1/calculate– run Safe Markdown PreviewGET https://safemarkdownpreview.usefulweb.site/api/v1/tool– inputs, output schema, examples- OpenAPI 3.1: /openapi.json · /openapi.yaml
- Errors:
application/problem+json;422includes per-fielderrors.
Safe Markdown Preview
Renders Markdown with headings, emphasis, lists, task lists, code, GFM tables, links, images, blockquotes and footnotes into HTML built from a strict allow-list. Raw HTML can be escaped, stripped or sanitised; scripts, event handlers, style attributes and javascript:/vbscript:/data: URLs are removed and listed in a security report. Shows a preview, the sanitised HTML source and a plain-text version.
| Field | Type | Default | Description |
|---|---|---|---|
markdown | textarea | — | Markdown |
file | file | — | Or upload a Markdown file |
rawHtml | select (sanitize, escape, strip) | "sanitize" | Raw HTML in the Markdown |
gfm | boolean | true | GitHub extensions (tables, task lists, strikethrough, bare URLs) |
footnotes | boolean | true | Footnotes ([^1]) |
allowDataImages | boolean | false | Allow base64 data: images (PNG/JPEG/GIF/WebP/AVIF; never SVG) |
Example request
Release notes with table, tasks and footnote
curl -X POST https://safemarkdownpreview.usefulweb.site/api/v1/calculate -H 'content-type: application/json' -d '{"markdown":"# Release notes\n\nVersion **2.4** brings _faster_ parsing, `inline code` and ~~old bugs~~ fixes.[^perf]\n\n- [x] Tables (GFM)\n- [ ] Footnotes\n- Links: [docs](https://example.com/docs \"Documentation\") and <https://usefulweb.site>\n\n| Feature | Status | Notes |\n|:--------|:------:|------:|\n| Tables | ✓ | GFM |\n| Images | ✓ | allow-listed |\n\n> Quote with a [reference link][ref].\n\n```js\nconsole.log(\"code is escaped: <b>\");\n```\n\n[ref]: https://commonmark.org/\n[^perf]: Measured on a 1 MB document.\n"}'
Every result contains
inputs (normalised, defaults applied), summary, result (validated against the published schema), units, assumptions, sources, warnings, computedAt and links.
MCP (Model Context Protocol)
- Streamable HTTP endpoint:
https://safemarkdownpreview.usefulweb.site/mcp– protocol revisions 2026-07-28 (stateless) and 2025-11-25 / 2025-06-18 / 2025-03-26 (initialize handshake). - Tools:
safe_markdown_preview - Local stdio connector:
node src/mcp-stdio.ts --tool=safe-markdown-preview
{
"mcpServers": {
"safe-markdown-preview": { "type": "http", "url": "https://safemarkdownpreview.usefulweb.site/mcp" }
}
}