/api/v1/validateValidate markdown API
Lint markdown for common issues.
POST /api/v1/validate is the Markdown Viewer API endpoint for linting markdown. Catches heading-increment jumps, missing space after #, inconsistent bullet style, excessive blank lines, and trailing whitespace — each issue tagged with line, rule, and severity.
Overview
Runs a conservative linter that reports heading-increment jumps, missing spaces after `#`, inconsistent bullets, multiple blank lines in a row, and trailing whitespace. Each issue points to a specific line number and rule id you can act on.
Request
Authenticate with Authorization: Bearer YOUR_API_KEY and send a JSON body containing the parameters below. Pick your language:
curl -X POST 'https://trymarkdownviewer.com/api/v1/validate' \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"markdown":"##Heading\n\n\n\n* bullet"}'Body parameters
| Field | Type | Required | Description |
|---|---|---|---|
| markdown | string | required | Markdown source. |
Response
Success responses are wrapped in a data field. Errors use { error: { code, message } } with an appropriate HTTP status — see the error reference.
{
"data": {
"valid": false,
"issueCount": 2,
"issues": [
{
"line": 1,
"message": "Missing space after `#` in heading.",
"rule": "heading-space",
"severity": "warning"
},
{
"line": 5,
"message": "Use `-` for unordered list items.",
"rule": "consistent-bullets",
"severity": "info"
}
]
}
}Use cases
Pull-request lint check
Run /api/v1/validate against changed markdown files in CI; fail the build if any issue exceeds 'info' severity.
CMS author guardrails
Surface lint issues inline in the author UI so editors can fix problems before publishing.
AI output gatekeeping
Validate LLM-produced markdown before persisting or displaying — catch malformed headings, missing language tags, and structural issues.
Production tips
- Each issue has a stable `rule` id — gate your CI on a specific subset rather than the whole linter.
- Severity is one of 'error', 'warning', or 'info' — adjust your failure threshold accordingly.
- Use validate as a fast pre-flight: it's typically faster than rendering and never modifies the document.
Validate markdown FAQ
- A conservative subset focused on portability and consistency: heading-space, heading-increment, consistent-bullets, multiple-blank-lines, trailing-whitespace, and missing-alt-text. Each rule emits a stable id you can pattern-match on.
- Not via the API today. The hosted endpoint runs a fixed, conservative ruleset designed to be safe for any project. If you need fine-grained control, run the same engine locally from the open-source repo and configure it there.
- No. The endpoint only reads the markdown and returns a list of issues. It never produces HTML or modifies the input — use /api/v1/format for fixes, /api/v1/render for HTML.
- Typically faster than /api/v1/render — there's no HTML generation, just a single pass over the document. Most documents under 32 KiB validate in under 30ms.
Which rules does /api/v1/validate apply?
Can I customise the ruleset?
Does validate render or modify the document?
How fast is /api/v1/validate?
Related endpoints
Try in browser
Free tools that run the same logic locally — no API key, no upload.
Try it
Send a real request against your account in the API playground. Errors there link straight back to the error reference.