# HTML Validator – Bulk W3C Nu Html Checker for URLs & Sitemaps (`adamplaenitz/html-validator`) Actor

Validate HTML of many URLs, a sitemap or a same-site crawl with the official W3C Nu Html Checker (vnu.jar) running inside the Actor. Errors and warnings per page with line, column and markup extract. Also checks pasted HTML.

- **URL**: https://apify.com/adamplaenitz/html-validator.md
- **Developed by:** [Adam Plänitz](https://apify.com/adamplaenitz) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 page validateds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## HTML Validator – Bulk W3C Nu Html Checker for URLs & Sitemaps

**Validate the HTML of many pages in one run with the Nu Html Checker (vnu.jar) – the same open-source checker that powers the W3C Markup Validation Service – running inside the Actor.** Give it a list of URLs, let it read a site's sitemap or follow links on the same site, or paste HTML directly. You get the number of errors, warnings and info messages per page plus every message with line, column and a short markup extract. Export as JSON, CSV or Excel, or connect to Google Sheets, Slack, Make, Zapier, n8n or webhooks.

### What does it do?

- **Fetches each page** (redirects are followed) and sends the HTML **unchanged, with its original character encoding**, to a local copy of the Nu Html Checker. HTML5 and XHTML (`application/xhtml+xml`) are supported; CSS in `<style>` elements and `style` attributes is checked as well.
- **Nothing is sent to validator.w3.org** – the checker runs inside the Actor container, so there are no rate limits of the public service and your pages are not uploaded to a third party.
- **Find more pages (optional):** read the **sitemap** of each site (from `robots.txt`, otherwise `/sitemap.xml`; sitemap indexes and `.xml.gz` supported) or **follow links** on the same site, both limited by *Maximum pages per site*. Include / exclude patterns and `robots.txt` are respected for discovered pages.
- **Pasted HTML:** validate an HTML document from the input field without publishing it anywhere.
- **Run summary** with totals and the 25 most frequent messages across all pages – handy for template-level problems that repeat on every page.

### Who is it for?

- **Web developers and agencies:** check a whole site after a release or before handing it over to a client.
- **SEO and accessibility audits:** invalid markup (unclosed elements, duplicate IDs, wrong nesting, bad ARIA attributes) is a common cause of rendering and accessibility problems.
- **QA / CI pipelines:** call the Actor via API with the HTML of a build and fail the pipeline on errors.
- **Monitoring:** schedule a weekly sitemap run and watch the error counts.

### Input

| Field | Default | Description |
|---|---|---|
| URLs | `https://apify.com`, `https://example.com` (prefill) | Pages to validate. Bare domains are checked as `https://domain/`. If neither URLs nor HTML are given, the two example pages are checked. |
| HTML to validate | – | Optional HTML document (max. 5 MB), returned as one result with `source: "html-input"`. |
| Find more pages of the same site | Only the listed URLs | `sitemap` or `links` (crawl). |
| Maximum pages per site | 20 | Including the start URL. |
| Maximum link depth | 3 | Only for *Follow links*. |
| Include subdomains | off | Treat `blog.example.com` as part of `example.com`. |
| Only / skip discovered URLs matching | – | Glob (`/blog/*`) or `/regex/` patterns. |
| Respect robots.txt | on | For discovered pages; start URLs are always validated. |
| List only errors | off | Messages list without warnings and info; the counts stay complete. |
| Maximum messages per page | 100 | `messagesTruncated` shows when the list was cut. 0 = counts only. |
| Include markup extracts | on | Short extract around each problem (markup only, see *Privacy*). |
| User-Agent, Parallel pages, Timeout | Actor UA, 4, 30 s | Advanced settings. |

### Output example (shortened)

```json
{
  "url": "https://www.python.org/",
  "finalUrl": "https://www.python.org/",
  "statusCode": 200,
  "source": "input",
  "valid": false,
  "errorCount": 6,
  "warningCount": 120,
  "infoCount": 3,
  "firstError": "Attribute “file-types” not allowed on element “script” at this point.",
  "messages": [
    {
      "type": "error",
      "message": "Attribute “file-types” not allowed on element “script” at this point.",
      "line": 9, "column": 90, "firstLine": 6, "firstColumn": 5,
      "extract": " <script defer file-types=\"bz2,chm,dmg,exe,gz,json,msi,msix,pdf,pkg,tgz,xz,zip\" data-domain=\"…\" src=\"https://analytics.python.org/js/script.file-downloads.outb…"
    },
    {
      "type": "warning",
      "message": "The element “a” with the attribute “href” should not appear as a descendant of an element with the attribute “role=menuitem”.",
      "line": 185, "column": 154, "firstLine": 185, "firstColumn": 86,
      "extract": "menuitem\"><a class=\"text-shrink\" title=\"…\" href=\"javascript:;\">…"
    }
  ],
  "messagesTruncated": true,
  "language": null,
  "validationTimeMs": 782,
  "contentType": "text/html; charset=utf-8",
  "htmlSizeBytes": 52061,
  "redirectCount": 0,
  "responseTimeMs": 40,
  "depth": 0,
  "foundOn": null,
  "validator": "Nu Html Checker (vnu.jar) 26.11.3",
  "checkedAt": "2026-11-20T19:54:10.449Z",
  "error": null,
  "errorCode": null
}
```

`type` is `error`, `warning` or `info` (the checker's "info" messages with sub-type "warning" are reported as `warning`; fatal parse errors have `"fatal": true`). `valid` is `true` when the page has no errors. Pages that could not be validated (DNS error, timeout, HTTP 4xx/5xx, not HTML, larger than 5 MB) appear as rows with `error` and `errorCode`.

The **Overview** table shows URL, valid, errors, warnings, info, first error, status, final URL, how the page was found, HTML size and error.

### Pricing and speed

See the **Pricing** tab. You pay per validated page (or pasted HTML document); **rows for pages that could not be validated – unreachable, HTTP errors, not HTML, invalid input – are free.** Pages skipped because of `robots.txt`, filters or the page limit are not stored and not charged. You can set a maximum cost per run – the Actor stops cleanly when it is reached.

The checker starts in about 2 seconds. In cloud tests with the default 2048 MB memory, 60 large pages (400–700 KB of HTML with 100+ errors each) took 54 seconds; 25 typical pages took under 5 seconds. With 1024 MB the Actor works as well but is slower on large pages (less CPU). Memory is split between the Java checker (45 %) and Node.js (25 %); give the Actor more memory for very large documents or higher parallelism.

### Validator, licence and attribution

- Validation is done by the **Nu Html Checker (vnu.jar)**, © Mozilla Foundation and contributors, released under the **MIT licence** (<https://github.com/validator/validator>). The official, unmodified `vnu.jar` from the `vnu-jar` npm package is used; it bundles third-party components under their own licences (listed inside the jar).
- Java runtime: Eclipse Temurin (GPLv2 with Classpath Exception).
- This Actor is **not affiliated with or endorsed by the W3C, WHATWG or Mozilla**. Results are the checker's messages for the HTML as it was delivered to the Actor; they are no certification.

### Privacy

- **No personal data is stored.** Markup extracts keep **tags only**: text content between tags and free-text attribute values (`alt`, `title`, `content`, `value`, `placeholder`, `aria-label`, `data-*` …) are replaced by `…`, and e-mail addresses and phone numbers are masked in extracts and messages. Extracts are at most 160 characters. You can switch extracts off completely.
- The HTML itself is not stored. Pasted HTML is only sent to the local checker inside the run.
- Private, loopback and internal addresses are refused.

### Limits

- The HTML is validated as delivered by the server, **without running JavaScript** – content added in the browser is not checked (the W3C service behaves the same way).
- Some sites answer automated clients with a bot-protection or error page (e.g. HTTP 403) – those rows are free; you can set a custom User-Agent.
- Documents larger than 5 MB are not validated. External CSS files and images are not checked.
- Line and column numbers refer to the source as delivered (often one long line for minified HTML).

Questions or feature requests? Please open an issue in the **Issues** tab.

# Actor input Schema

## `urls` (type: `array`):

Pages to validate, one per line. Bare domains are checked as https://domain/. Duplicates are removed. If both this field and 'HTML to validate' are empty, the example pages https://apify.com and https://example.com are checked.

## `html` (type: `string`):

Optional: paste an HTML document (max. 5 MB) to validate it directly, without fetching a URL. It is returned as one extra result with source 'html-input'.

## `discoverPages` (type: `string`):

'Only the listed URLs' validates exactly the URLs above. 'Sitemap' reads the sitemap(s) of each site (from robots.txt, otherwise /sitemap.xml). 'Follow links' crawls links on the same site. Both are limited by 'Maximum pages per site'.

## `maxPagesPerSite` (type: `integer`):

Upper limit of validated pages per site (host without 'www.') including the start URL, when pages are discovered via sitemap or links.

## `maxDepth` (type: `integer`):

Only for 'Follow links': how many clicks away from the start URL pages may be.

## `includeSubdomains` (type: `boolean`):

Treat subdomains (e.g. blog.example.com for example.com) as the same site when discovering pages.

## `includePatterns` (type: `array`):

Optional glob patterns (e.g. '/blog/*' for path + query, or 'https://example.com/docs/*') or /regular expressions/. Discovered pages must match one of them. Start URLs are always validated.

## `excludePatterns` (type: `array`):

Optional glob patterns or /regular expressions/ for discovered pages that should not be validated (e.g. '/tag/\*').

## `respectRobotsTxt` (type: `boolean`):

Discovered pages disallowed by robots.txt (for 'html-validator') are skipped. Start URLs are always validated.

## `onlyErrors` (type: `boolean`):

The messages list contains only errors (no warnings or info messages). The counts always include all message types.

## `maxMessagesPerPage` (type: `integer`):

Caps the messages list of each page (the counts are always complete; 'messagesTruncated' shows when the list was cut). 0 = counts only.

## `includeExtracts` (type: `boolean`):

Adds a short extract of the markup around each problem. Only tags are kept: text content and free-text attribute values (alt, title, content, value …) are replaced by '…', e-mail addresses and phone numbers are masked.

## `userAgent` (type: `string`):

Leave empty to identify as 'Mozilla/5.0 (compatible; html-validator/0.1; Apify Actor; +https://apify.com)'.

## `maxConcurrency` (type: `integer`):

How many pages are fetched and validated at the same time (1–10, at most 3 per host).

## `timeoutSecs` (type: `integer`):

Inactivity timeout for fetching a page (until the response starts and between two data chunks).

## Actor input object example

```json
{
  "urls": [
    "https://apify.com",
    "https://example.com"
  ],
  "discoverPages": "none",
  "maxPagesPerSite": 20,
  "maxDepth": 3,
  "includeSubdomains": false,
  "respectRobotsTxt": true,
  "onlyErrors": false,
  "maxMessagesPerPage": 100,
  "includeExtracts": true,
  "maxConcurrency": 4,
  "timeoutSecs": 30
}
```

# Actor output Schema

## `results` (type: `string`):

One item per page with error / warning counts and the validator messages (type, text, line, column, markup extract).

## `summary` (type: `string`):

Totals, most frequent messages, skipped pages, error codes and charged results.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://apify.com",
        "https://example.com"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("adamplaenitz/html-validator").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": [
        "https://apify.com",
        "https://example.com",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("adamplaenitz/html-validator").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://apify.com",
    "https://example.com"
  ]
}' |
apify call adamplaenitz/html-validator --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,adamplaenitz/html-validator"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/5w6OT7CfuhasHo0ZF/builds/2sVoZvnUF9AjsREbC/openapi.json
