HTML Tidy  5.4.0
The HTACG Tidy HTML Project
About HTML Tidy


HTML Tidy and LibTidy correct and clean up HTML content by fixing markup errors such as mismatched, mis-nested, and missing tags; missing end "/" tags; missing quotations; and many, many more discrepant conditions, and serves as an HTML pretty printer.

For example…

1 <h1><hr>heading</h1>
2 <h2>sub<hr>heading</h2>
3 <a href="#refs">References<a>

…can be converted to

1 <hr>
2 <h1>heading</h1>
3 <h2>sub</h2>
4 <hr>
5 <h2>heading</h2>
6 <a href="#refs">References</a>

About this Documentation

This documentation is intended to serve as reference materials for both developers and LibTidy implementers so that they can have a reference for troubleshooting code, fixing issues with Tidy, and for implementing their own programs with LibTidy’s API.

Consumer documentation can be referenced from tidy -help on all platforms, and via man tidy on Unix platforms.

In addition to the automatically generated documentation from Tidy’s source code, these three major sections provide practical information about using Tidy, how to contribute, and how LibTidy works:

  • General
    • These articles show how HTML Tidy works from a user perspective. Although the console program is described, keep in mind that all of these articles apply to LibTidy, too, as the console is simply one type of clients to the library.
  • LibTidy
    • High level information about LibTidy is discussed in this series of articles, including a sample implementation of the library.
  • Programming
    • These articles detail how to work with the HTML Tidy source code. If you plan to work with HTACG and donate your own contributions, please have a look at these articles so that you have an easy transition to our team!


HTML Tidy is composed of two major components:

Tidy Console

Tidy’s console program is the piece that most people interact with in their console or terminal application. It implements LibTidy on macOS, Linux and other Unixes, Windows, and more, and is a relatively simple program that can serve as a good reference model for programs wishing to implement LibTidy.

General information about the console application is available in General.


The critical mass of Tidy consists of LibTidy, a C static or dynamic library (your choice) that developers can integrate into their own program in order to bring all of Tidy’s power to your favorite tools.

An introduction to LibTidy is available in LibTidy, and some helpful guides are present in the Programming section, too.