HTML Tidy  5.2.0
The HTACG Tidy HTML Project
tidy command quickstart

This is the syntax for invoking Tidy from the command line:

1 tidy [[options] filename]

Tidy defaults to reading from standard input, so if you run Tidy without specifying the filename argument, it will just sit there waiting for input to read.

Tidy defaults to writing to standard output. So you can pipe output from Tidy to other programs, as well as pipe output from other programs to Tidy. You can page through the output from Tidy by piping it to a pager, e.g.:

1 tidy file.html | less

Output to file

To have Tidy write its output to a file instead, either use the

1 -o filename
2 or
3 -output filename

option, or redirect standard output to the file. For example:

1 tidy -o output.html index.html
2 tidy -output output.html index.html
3 tidy index.html > output.html

All the above run Tidy on the file index.html and write the output to the file output.html, while writing any error messages to standard error.

Error output

Tidy defaults to writing its error messages to standard error (that is, to the console where you’re running Tidy). To page through the error messages along with the output, redirect standard error to standard output, and pipe it to your pager:

1 tidy index.html 2>&1 | less

To have Tidy write the errors to a file instead, either use

1 -f filename
2 or
3 -file filename

option, or redirect standard error to a file:

1 tidy -o output.html -f errs.txt index.html
2 tidy index.html > output.html 2> errs.txt

Both the above run Tidy on the file index.html and writes the output to the file output.html, while writing any error messages to the file errs.txt.

Writing the error messages to a file is especially useful if the file you are checking has many errors; reading them from a file instead of the console or pager can make it easier to review them.

Modify / Overwrite

You can use the or -m or -modify option to modify (in-place) the contents of the input file you are checking; that is, to overwrite those contents with the output from Tidy. For example:

1 tidy -f errs.txt -m index.html

That runs Tidy on the file index.html, modifying it in place and writing the error messages to the file errs.txt.

Warning
If you use the -m option, you should first ensure that you have a backup copy of your file.