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.

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

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

NameInTypeRequiredDefault
htmlbodystringnoHTML source (max 3,000,000 characters). Or send url or a file.
urlquerystringnoPublic page to fetch and validate.
presetbody|querystringnorecommendedrecommended, standard (no accessibility rules) or a11y.
disablebody|querystringnoComma-separated rule ids to skip (e.g. attribute-unknown,viewport-missing).
levelbody|querystringnoinfoMinimum severity returned: error, warning or info.
fragmentbody|querybooleannoForce fragment (1) or full-document (0) mode; default auto.
list_rulesbody|querybooleanno1: 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>"}'

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

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