Markdown Lint & Fix API
Lint Markdown with the markdownlint rules (MD001–MD060), auto-fix what can be fixed, generate a table of contents and find broken internal links.
Send Markdown as markdown, a file, a URL (e.g. a raw README) or a .zip of docs. You get every problem from markdownlint's rule set — heading levels, list indentation and style, line length, blank lines around headings / lists / fences, bare URLs, empty links, images without alt, code blocks without a language, link fragments… — with line, column, rule id and alias, description and a link to the rule docs. Configure with config (the usual .markdownlint.json object), preset=relaxed, disable / enable lists or line_length.
fix=1 applies every automatic fix (repeated until stable) and returns the fixed text plus what remains. toc=1 builds a table of contents with GitHub-style anchors (toc_min / toc_max levels) and, with insert_toc=1 or fix=1, writes it between <!-- toc --> and <!-- tocstop --> markers. Internal links are checked: #anchors against the headings (with GitHub duplicate suffixes) and explicit ids, undefined reference links, and — for a ZIP — relative links to files and to headings inside other files.
Uses markdownlint (MIT). Custom JavaScript rules are not accepted.
Markdown · OpenAPI · Postman · llms.txt
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
markdown | body | string | no | Markdown text (max 2,000,000 characters). Or send url, a file or a .zip. | |
file | body | file | no | A .md file or a .zip of Markdown files (batch). | |
config | body | object | no | markdownlint configuration, e.g. {"MD013": {"line_length": 120}, "MD033": false}. | |
preset | body|query | string | no | default | default or relaxed (no line length, inline HTML, bare URL, code-language and first-line rules). |
disable | body|query | string | no | Rules to turn off, e.g. MD013,MD041. | |
fix | body|query | boolean | no | 1: return the auto-fixed Markdown. | |
toc | body|query | boolean | no | 1: generate a table of contents (toc_min, toc_max, default 2–3). | |
insert_toc | body|query | boolean | no | 1: write the TOC between <!-- toc --> and <!-- tocstop -->. |
Example
curl -X POST "https://apibox.io.vn/v1/markdown-lint" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"markdown":"# Project\n\n<!-- toc -->\n<!-- tocstop -->\n\n## Install\nRun it:\n```\nnpm i\n```\n## Usage\nSee [install](#install) and [api](#api).\n","fix":true,"toc":true}'const res = await fetch('https://apibox.io.vn/v1/markdown-lint', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"markdown": "# Project\n\n<!-- toc -->\n<!-- tocstop -->\n\n## Install\nRun it:\n```\nnpm i\n```\n## Usage\nSee [install](#install) and [api](#api).\n",
"fix": true,
"toc": true
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/markdown-lint",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"markdown": "# Project\n\n<!-- toc -->\n<!-- tocstop -->\n\n## Install\nRun it:\n```\nnpm i\n```\n## Usage\nSee [install](#install) and [api](#api).\n", "fix": True, "toc": True},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/markdown-lint');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"markdown":"# Project\\n\\n<!-- toc -->\\n<!-- tocstop -->\\n\\n## Install\\nRun it:\\n```\\nnpm i\\n```\\n## Usage\\nSee [install](#install) and [api](#api).\\n","fix":true,"toc":true}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"valid": false,
"input": "markdown",
"errors": 2,
"by_rule": {
"MD040": 1,
"MD051": 1
},
"messages": [
{
"line": 14,
"rule": "MD040",
"alias": "fenced-code-language",
"description": "Fenced code blocks should have a language specified",
"context": "```",
"fixable": false,
"severity": "error",
"info": "https://github.com/DavidAnson/markdownlint/blob/v0.42.1/doc/md040.md"
},
{
"line": 20,
"rule": "MD051",
"alias": "link-fragments",
"description": "Link fragments should be valid",
"context": "[api](#api)",
"column": 29,
"length": 11,
"fixable": false,
"severity": "error",
"info": "https://github.com/DavidAnson/markdownlint/blob/v0.42.1/doc/md051.md"
}
],
"broken_links": [
{
"line": 20,
"link": "#api",
"problem": "anchor_not_found"
}
],
"headings": 3,
"fixed": "# Project\n\n<!-- toc -->\n\n- [Install](#install)\n- [Usage](#usage)\n\n<!-- tocstop -->\n\n## Install\n\nRun it:\n\n```\nnpm i\n```\n\n## Usage\n\nSee [install](#install) and [api](#api).\n",
"changed": true,
"toc": "- [Install](#install)\n- [Usage](#usage)",
"toc_inserted": true,
"markdownlint": "0.42.1",
"preset": "default"
}
Use cases
- Keep README and docs-as-code repositories consistent in CI
- Clean up Markdown written by an LLM or a headless CMS before publishing
- Generate and refresh a table of contents automatically
- Find broken #anchor and relative file links across a documentation ZIP
FAQ
Which rules are applied?
All markdownlint rules (MD001–MD060) with their defaults; pass a config object like your .markdownlint.json or preset=relaxed for prose-friendly settings.
Are the line numbers from my original text?
Yes, unless fix=1 or a TOC was inserted: then they refer to the returned fixed text.
Can I lint a whole docs folder?
Yes, upload it as a ZIP (up to 300 Markdown files); links between files are checked too.
Related APIs
HTML to Markdown
Convert HTML or any web page URL into clean GitHub-flavored Markdown, with tables, optional article extraction and absolute links.
</>Markdown to HTML
Render GitHub-flavored Markdown to HTML with tables and strikethrough. Output is sanitized by default to strip scripts and event handlers.
<✓>HTML Sanitizer
Strip scripts, iframes, forms, event handlers, inline styles and javascript: links from untrusted HTML before you display it.