tidyp is a program that can validate your HTML, as well as modify it to be more clean and standard. tidyp does not validate HTML 5.
Homepage Repository Homebrew C
brew install tidyp
tidyp is a fork of tidy on SourceForge at http://tidy.sf.net. The library name is "tidyp", and the command-line tool is also "tidyp" but all internal API stays the same. tidyp will validate your HTML, and output cleaned-up HTML. The tidyp homepage is at http://tidyp.com/. For installation instructions, see INSTALL.