{"id":17685,"library":"html-validator-cli","title":"HTML Validator CLI","description":"html-validator-cli is a command-line interface tool for validating HTML documents against the W3C's validator.w3.org/nu service. It offers a straightforward way to check HTML files, URLs, or raw HTML strings directly from the terminal. The current stable version is 7.0.1. The project demonstrates a moderate release cadence, with several patch and minor updates, and significant major version bumps (6.0.0, 7.0.0) tied to underlying `html-validator` library updates and Node.js engine requirement changes. Key differentiators include support for various output formats (JSON, HTML, text), the ability to ignore specific error messages, and options to validate local files or use a custom validator endpoint. It simplifies HTML validation workflows for developers by integrating directly into shell scripts and CI/CD pipelines without needing a browser or GUI.","status":"active","version":"7.0.1","language":"javascript","source_language":"en","source_url":"https://github.com/zrrrzzt/html-validator-cli","tags":["javascript","html-validator","validation","cli"],"install":[{"cmd":"npm install html-validator-cli","lang":"bash","label":"npm"},{"cmd":"yarn add html-validator-cli","lang":"bash","label":"yarn"},{"cmd":"pnpm add html-validator-cli","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency providing the HTML validation logic against validator.w3.org/nu.","package":"html-validator","optional":false}],"imports":[],"quickstart":{"code":"{\n  \"name\": \"my-html-project\",\n  \"version\": \"1.0.0\",\n  \"description\": \"Validate HTML files in my project\",\n  \"scripts\": {\n    \"validate:url\": \"html-validator https://example.com --format=json\",\n    \"validate:file\": \"html-validator --file=./public/index.html --verbose\",\n    \"validate:data\": \"html-validator --data='<!DOCTYPE html><html><body><h1>Hello</h1></body></html>'\"\n  },\n  \"devDependencies\": {\n    \"html-validator-cli\": \"^7.0.0\"\n  }\n}\n\n// To run from the command line after npm install:\n// npm run validate:url\n// npm run validate:file\n// npm run validate:data","lang":"javascript","description":"Demonstrates how to install html-validator-cli as a dev dependency and use it via npm scripts to validate a URL, a local file, or an HTML string."},"warnings":[{"fix":"Upgrade your Node.js environment to version 10.22.0 or newer. If you must use an older Node.js, install an older version of html-validator-cli (e.g., `npm install html-validator-cli@6` for Node.js >= 8.15.3, or `npm install html-validator-cli@5` for older environments).","message":"Node.js engine requirement increased significantly. Version 7.x now requires Node.js >= 10.22.0. Previously, v6.x required Node.js >= 8.15.3, and v5.x supported older Node.js versions.","severity":"breaking","affected_versions":">=7.0.0"},{"fix":"Carefully review the release notes for both `html-validator-cli` and `html-validator` when upgrading major versions. Test your validation workflows thoroughly to ensure expected output and behavior.","message":"Major version updates often coincide with significant changes in the underlying `html-validator` library (e.g., v6.x updated to `html-validator@4`, v7.x updated to `html-validator@5`). While the CLI aims to abstract these, subtle changes in error reporting, parsing, or supported features might occur.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Always use `html-validator <local-url> --islocal` when validating HTML served from a local development server.","message":"The `--islocal` flag is crucial for validating local development URLs without exposing them publicly. Failing to use this flag for `http://localhost:...` or similar URLs will result in 'Page not found' errors as the W3C validator cannot access them.","severity":"gotcha","affected_versions":">=6.0.0"},{"fix":"To get detailed validation results, use `html-validator ... --verbose` or specify an output format like `html-validator ... --format=json`.","message":"By default, the CLI outputs 'Page is valid' or 'Page is not valid' to STDOUT and exits with code 0 or 1 respectively. Detailed error messages are suppressed unless `--verbose` is used or a specific `--format` is chosen.","severity":"gotcha","affected_versions":">=4.0.0"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Ensure the URL is publicly accessible or, if validating a local development server, use the `--islocal` flag (e.g., `html-validator http://localhost:8000 --islocal`). Check the URL for typos.","cause":"The validator could not access the provided URL, most commonly due to a local URL not being accessible from the W3C validator service or a typo in the URL.","error":"Error: Command failed with exit code 1\nPage not found"},{"fix":"Install the package globally using `npm i -g html-validator-cli` or run it using `npx html-validator ...` to execute it without global installation.","cause":"The `html-validator-cli` package was not installed globally or is not in the system's PATH, or `npx` is not being used.","error":"Error: 'html-validator' is not recognized as an internal or external command, operable program or batch file."},{"fix":"Upgrade your Node.js version to 10.22.0 or newer. Alternatively, install an older compatible version of `html-validator-cli` (e.g., `npm install -g html-validator-cli@6` for Node.js >= 8.15.3).","cause":"Your installed Node.js version is older than the minimum required by html-validator-cli v7.x.","error":"The 'engines' field in package.json specifies a Node.js version (>=10.22.0) that is not satisfied by your current environment."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}