Easily Clean Dirty HTML

0 Comments | This entry was posted on Apr 21 2009

I have possibly discovered the best little tool around – Tidy.

I have just had to work on a site where the combination of a Skype toolbar and a html Wysiwyg created some dirty code that stopped the Wysiwyg from working.

I was left with a mess that included many javascript snippets and all round bad code that existed all on the one line. Doing a quick search brought me to a small Linux app called Tiny. It will instantly open the dirty file, remove bad or orhpaned elements, cleanly indent the code leaving the output validated as XHTML 1.0 Transitional.

A great tool and time saver.

Installation for Debian like systems including Ubuntu

sudo apt-get install tidy

Usage from the terminal

tidy -f error_filename.txt -imu dirtyfile.html