HTML Tidy is a tool for checking and cleaning up HTML source files. 

It is especially useful for finding and correcting errors in deeply nested HTML, or for making grotesque code legible once more.

A popular tool for converting HTML files to XHMTL

The latest versions of the source code can be found at the Source Forge developer's site for Tidy, see

more info: