Using the Command Line Interface

The html-validate CLI can be installed with npm:

npm i -g html-validate

To run html-validate use:

html-validate [OPTIONS] [FILE|DIR|GLOB...]

Since globs will usually be expanded by your shell remember to quote the pattern if you require node glob syntax:

html-validate "src/**/*.html"



This option specifies the file extensions to use when searching for files in directories. By default only .html files are searched. This option is ignored when specifying files or globs.

Multiple extensions can be set with a comma-separated list: --ext html,vue. Leading dots are ignored.

html-validate --ext html,vue src

-f, --formatter

Specify which formatter(s) to use. Possible formats are:

Multiples formatters can be set with a comma-separated list: --formatter stylish,checkstyle. Output can be redirected to a file using name=path: --formatter checkstyle=result.xml.

Custom formatters can be used by specifying a package name: --formatter my-custom-formatter.

html-validate --formatter stylish file.html


Exits with non-zero status if more when more than given amount of warnings occurs. Use 0 to disallow warnings.

html-validate --max-warnings 0 file.html


Inline rule configuration. Rule severity can have the following string or numeric value:

Configurations can be changed with an array of rules: --rule [void:2, foo:0].

html-validate --rule void:2 file.html

Note: rules replaces existing configuration!


Process markup from stdin. The special alias - can also be set as a filename to use stdin.

curl | html-validate --stdin


Filename to set in report when using --stdin.

curl | html-validate --stdin --stdin-filename

Debugging options

The options are intended for debugging purposes.


Instead of validating file print the event stream generated.

html-validate --dump-events file.html


Instead of validating file print the token stream generated.

html-validate --dump-token file.html


Instead of validating file print the DOM tree generated.

html-validate --dump-tree file.html

Miscellaneous options

-c, --config

Specify a different configuration file.

html-validate --config myconfig.json file.html

Note that specifying a separate configuration file changes the default configuration but .htmlvalidate.json files will still be searched from the filesystem. Set the root property to true to prevent this behavior:

  "root": true


Initialize project with a new configuration.

html-validate --init

The new configuration will be written to the current directory (in .htmlvalidate.json).

Instead of validating a file, print the effective configuration that would be used. Requires a single filename.

html-validate --print-config file.html

-h, --help

Show help.


Show version number