npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

w3c-validate-html

v1.1.0

Published

Validate HTML offline using the official W3C vnu.jar

Readme

w3c-validate-html

Tests license npm

Validate HTML offline using the official W3C vnu.jar

Why? Modern build tools can introduce HTML bugs. w3c-validate-html runs locally and prints concise, clickable errors with line numbers using the same rules as the online W3C validator.

CLI

The easiest way to use this is from the CLI using npx, for example:

# validate a website recursively (default depth 2)
npx w3c-validate-html --target https://example.com --depth 1 --errors-only

# Validate a folder, fail only on errors
npx w3c-validate-html --target ./public --errors-only

Options

Option | Alias | Type | Default | Description :-------------|:------|:--------|:-------------------|:--------------------------------------- --target | -t | string | | File, folder, URL or string to validate --depth | | number | 2 | Crawl depth for website validation --concurrency | | number | 4 | Number of concurrent validations --warnings | | number | 1 | Show warnings (0 = off, 1 = on) --exclude | | string | | Comma/space separated URLs to exclude --errors-only | -e | boolean | false | Only show errors --json | | boolean | false | Output results as JSON --same-origin | | boolean | true | Restrict crawl to same origin --strip-query | | boolean | false | Exclude URLs with query strings --user-agent | | string | Mozilla/5.0 (node) | Custom user agent for requests

Output

Errors and warnings include clickable file:line:col links for quick editor navigation.

  ✖ public/invalid.html
      End tag for  "h1" seen, but there were unclosed elements. public/invalid.html:7:5
      Unclosed element "h1". public/invalid.html:7:5
      End of file seen when expecting text or an end tag. public/invalid.html:9:1
  ✔ public/valid.html

Node module

You can use this package as a node module to validate a URL, file/folder, or raw HTML string:

Validate a URL

const validate = require('w3c-validate-html');

validate('https://example.com', { warnings: 1, depth: 0 }).then(function(summary) {
    console.log(summary);
})
.catch((err) => {
    console.error(err);
});

Validate a local file or folder

const validate = require('w3c-validate-html');

validate('./tests/fixtures/valid.html', { warnings: 1 }).then(function(summary) {
    console.log(summary);
})
.catch((err) => {
    console.error(err);
});

Validate a HTML string

const validate = require('w3c-validate-html');

var html = '<!DOCTYPE html><html><head><title>Test</title></head><body><h1>Hi</h1></body></html>';

validate(html).then(function(result) {
    console.log(result);
})
.catch((err) => {
    console.error(err);
});

Example response

{
  "passed": 0,
  "failed": 1,
  "results": [
    {
      "ok": false,
      "errors": [
        { "line": 7, "col": 5, "msg": "End tag for  \"h1\" seen, but there were unclosed elements." },
        { "line": 7, "col": 5, "msg": "Unclosed element \"h1\"." },
        { "line": 9, "col": 1, "msg": "End of file seen when expecting text or an end tag." }
      ],
      "warnings": []
    }
  ]
}

GitHub Action

You can use this in your CI as a Github Action to validate your site's HTML on every push and pull request. The job fails if any pages have HTML errors and a html-report.json artifact is uploaded for review.

name: html-validate
on: [push, pull_request]

jobs:
  html-validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/setup-node@v4
        with:
          node-version: 18

      - name: validate url
        env:
          TARGET_URL: https://example.com
        run: npx w3c-validate-html --target "$TARGET_URL" --depth 2 --errors-only --json > html-report.json

      - uses: actions/upload-artifact@v4
        with:
          name: html-report
          path: html-report.json

See also

License

MIT License © Orca Scan - a barcode app with simple barcode tracking APIs.