HTML Validator API
Validate HTML from a string, file or URL: unclosed and misnested tags, invalid or obsolete elements and attributes, duplicate ids, missing alt / lang.
Checks HTML the way a browser parser reads it and reports each problem with line, column, rule, severity and a snippet: unclosed, stray and misnested tags (<b><i></b></i>), end tags on void elements, <div/> self-closing syntax, block elements that silently close a <p>, unknown and obsolete elements (<center>, <font>, <marquee>…), obsolete presentational attributes (align, bgcolor, cellpadding…), attributes not defined for the element, invalid enumerated values (type="emial"), boolean attributes written as disabled="false", duplicate attributes and ids, broken id references (for, aria-labelledby), content-model errors (div in span, button in a, li outside a list, td outside tr, nested forms), and document checks (doctype, charset, title, viewport).
Basic accessibility rules are included: images without alt, form controls without a label, links and buttons without an accessible name, empty headings, skipped heading levels, iframes without title, zoom disabled by the viewport, autoplay with sound. Choose preset=recommended (all), standard (no accessibility rules) or a11y; turn rules off with disable=; filter with level=error|warning|info. Fragments are recognised automatically (no document-level rules).
It is a fast static checker (own engine), not the W3C Nu validator. For a full WCAG audit with axe-core use /v1/a11y-check; for SEO checks use the SEO endpoints.
Markdown · OpenAPI · Postman · llms.txt
Parameters
| Name | In | Type | Required | Default | |
|---|---|---|---|---|---|
html | body | string | no | HTML source (max 3,000,000 characters). Or send url or a file. | |
url | query | string | no | Public page to fetch and validate. | |
preset | body|query | string | no | recommended | recommended, standard (no accessibility rules) or a11y. |
disable | body|query | string | no | Comma-separated rule ids to skip (e.g. attribute-unknown,viewport-missing). | |
level | body|query | string | no | info | Minimum severity returned: error, warning or info. |
fragment | body|query | boolean | no | Force fragment (1) or full-document (0) mode; default auto. | |
list_rules | body|query | boolean | no | 1: include the list of rules. |
Example
curl -X POST "https://apibox.io.vn/v1/html-validate" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"html":"<!doctype html>\n<html>\n<head><title>Shop</title></head>\n<body>\n<p>Intro <div>Sale</div></p>\n<img src=\"banner.png\">\n<a href=\"/cart\"><button>Cart</button></a>\n<div id=\"x\"></div><div id=\"x\" align=\"center\"></div>\n</body>\n</html>"}'const res = await fetch('https://apibox.io.vn/v1/html-validate', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"html": "<!doctype html>\n<html>\n<head><title>Shop</title></head>\n<body>\n<p>Intro <div>Sale</div></p>\n<img src=\"banner.png\">\n<a href=\"/cart\"><button>Cart</button></a>\n<div id=\"x\"></div><div id=\"x\" align=\"center\"></div>\n</body>\n</html>"
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/html-validate",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"html": "<!doctype html>\n<html>\n<head><title>Shop</title></head>\n<body>\n<p>Intro <div>Sale</div></p>\n<img src=\"banner.png\">\n<a href=\"/cart\"><button>Cart</button></a>\n<div id=\"x\"></div><div id=\"x\" align=\"center\"></div>\n</body>\n</html>"},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/html-validate');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"html":"<!doctype html>\\n<html>\\n<head><title>Shop</title></head>\\n<body>\\n<p>Intro <div>Sale</div></p>\\n<img src=\\"banner.png\\">\\n<a href=\\"/cart\\"><button>Cart</button></a>\\n<div id=\\"x\\"></div><div id=\\"x\\" align=\\"center\\"></div>\\n</body>\\n</html>"}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));Response
{
"valid": false,
"input": "html",
"preset": "recommended",
"document": true,
"errors": 6,
"warnings": 2,
"infos": 1,
"by_rule": {
"lang-missing": 1,
"p-implied-close": 1,
"close-stray": 1,
"img-alt": 1,
"interactive-nesting": 1,
"id-duplicate": 1,
"attribute-obsolete": 1,
"charset-missing": 1,
"viewport-missing": 1
},
"messages": [
{
"rule": "charset-missing",
"severity": "warning",
"category": "document",
"message": "No <meta charset=\"utf-8\">",
"line": 1,
"column": 1,
"snippet": "<!doctype html>"
},
"…",
{
"rule": "p-implied-close",
"severity": "warning",
"category": "content",
"message": "<div> is not allowed inside <p>; the <p> opened on line 5 is closed here, so a later </p> will be stray",
"line": 5,
"column": 10,
"element": "div",
"snippet": "<p>Intro <div>Sale</div></p>"
},
{
"rule": "close-stray",
"severity": "error",
"category": "syntax",
"message": "</p> without an open <p> (often a block element closed the paragraph earlier)",
"line": 5,
"column": 25,
"element": "p",
"snippet": "<p>Intro <div>Sale</div></p>"
},
{
"rule": "img-alt",
"severity": "error",
"category": "a11y",
"message": "<img src=\"banner.png\"> has no alt (use alt=\"\" for decorative images)",
"line": 6,
"column": 1,
"element": "img",
"snippet": "<img src=\"banner.png\">"
},
{
"rule": "interactive-nesting",
"severity": "error",
"category": "content",
"message": "<button> (interactive) inside <a>",
"line": 7,
"column": 17,
"element": "button",
"snippet": "<a href=\"/cart\"><button>Cart</button></a>"
},
{
"rule": "id-duplicate",
"severity": "error",
"category": "attribute",
"message": "Duplicate id \"x\" (first used on line 8)",
"line": 8,
"column": 24,
"element": "div",
"snippet": "<div id=\"x\"></div><div id=\"x\" align=\"center\"></div>"
},
{
"rule": "attribute-obsolete",
"severity": "error",
"category": "attribute",
"message": "Attribute \"align\" on <div> is obsolete: use CSS text-align / margin",
"line": 8,
"column": 31,
"element": "div",
"snippet": "<div id=\"x\"></div><div id=\"x\" align=\"center\"></div>"
}
],
"see_also": "Full WCAG audit with axe-core: /v1/a11y-check"
}
Use cases
- Validate HTML generated by a CMS, template engine or LLM before publishing
- Catch broken markup in e-mail and invoice templates
- Add an HTML check to CI without running a Java validator
- Give content editors a list of missing alt texts and labels
FAQ
Is this the W3C validator?
No. It is an independent checker of the most common conformance and nesting errors with exact positions; it is faster and has no rate limit for commercial use.
Does it run JavaScript?
No. Only the HTML source is checked; script and style contents are skipped.
How is it different from a11y-check?
html-validate finds markup errors plus a few accessibility basics; a11y-check runs axe-core for a full WCAG audit (contrast, ARIA, landmarks…).
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.