Reuse IE (WebBrowser & MSHTML) might be a simple choice. But there is some performance overhead.
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/editing/mshtmleditor.asp
http://msdn.microsoft.com/library/default.asp?url=/workshop/browser/editing/mshtmleditor.asp
Another one is Tidy:
http://www.w3.org/People/Raggett/tidy/