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.

GETPOSThttps://apibox.io.vn/v1/markdown-lint
Content & HTML▶ Try it online

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

NameInTypeRequiredDefault
markdownbodystringnoMarkdown text (max 2,000,000 characters). Or send url, a file or a .zip.
filebodyfilenoA .md file or a .zip of Markdown files (batch).
configbodyobjectnomarkdownlint configuration, e.g. {"MD013": {"line_length": 120}, "MD033": false}.
presetbody|querystringnodefaultdefault or relaxed (no line length, inline HTML, bare URL, code-language and first-line rules).
disablebody|querystringnoRules to turn off, e.g. MD013,MD041.
fixbody|querybooleanno1: return the auto-fixed Markdown.
tocbody|querybooleanno1: generate a table of contents (toc_min, toc_max, default 2–3).
insert_tocbody|querybooleanno1: 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}'

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

Start with 1,000 free requests every month. Get free API key →