Introduction

HtmlCleaner is an open source HTML parser written in Java. HTML found on the Web is usually dirty, ill-formed and unsuitable for further processing. For any serious consumption of such documents, it is necessary to first clean up the mess and bring some order to the tags, attributes and ordinary text. For any given HTML document, HtmlCleaner reorders individual elements and produces well-formed XML. By default, it follows similar rules that the most of web browsers use in order to create the Document Object Model. However, you can provide custom tag and rule sets for tag filtering and balancing.

Contributing

Like any open source project we rely on the contributions from our community. In each of our releases you can see how community patches and bug fixes drive the project forwards. (You could even contribute a much nicer public website than this one :) So please do contribute!

If, on the other hand, you make a lot of use of HtmlCleaner but can't contribute time or code, you can make a donation instead. I (Scott Wilson) maintain HtmlCleaner releases in my spare time, so any donations are very welcome!

Support

Free support is available through our community forums. Commercial support is available from Cetis LLP - email info@cetis.org.uk for more details.

If your company offers HtmlCleaner support, let me know and I'll add your details here.

Latest News

HtmlCleaner has been fixing shoddy HTML since 2006! Below are the most recent releases.

June 19th 2023: HtmlCleaner 2.29 released!

Fix for stack overflow error with CVE notice, and a build change

For more details see the release notes.

April 29th 2023: HtmlCleaner 2.28 released!

Various fixes related to HTML5 spec changes

For more details see the release notes.

March 24th 2023: HtmlCleaner 2.27 released!

Updated POM to target jdk 1.8

For more details see the release notes.

January 18th 2022: HtmlCleaner 2.26 released!

Updates JDOM version to mitigate CVE-2021-33813

For more details see the release notes.

September 24th 2021: HtmlCleaner 2.25 released!

Bug fixes.

For more details see the release notes.

April 29th 2020: HtmlCleaner 2.24 released!

Various bug fixes, and a new experimental serializer

For more details see the release notes.

September 6th 2019: HtmlCleaner 2.23 released!

Various bug fixes, with thanks to our friends at Screaming Frog!

For more details see the release notes.

April 24th 2018: HtmlCleaner 2.22 released!

Various bug fixes.

For more details see the release notes.

May 11th 2017: HtmlCleaner 2.21 released!

Bugfix release - regression in PruneTags.

For more details see the release notes.

May 2nd 2017: HtmlCleaner 2.20 released!

Improvements to attribute handling, extra Ant properties and more.

For more details see the release notes.

February 7th 2017: HtmlCleaner 2.19 released!

Various bug fixed and stability improvements.

For more details see the release notes.

November 2nd 2016: HtmlCleaner 2.18 released!

Fixed a build error affecting command line use.

For more details see the release notes.

October 19th 2016: HtmlCleaner 2.17 released!

A small number of bug fixes in this release.

For more details see the release notes.

December 2nd 2015: HtmlCleaner 2.16 released!

Various bug fixes in this release, and more improvements to character handling

For more details see the release notes.

October 1st 2015: HtmlCleaner 2.15 released!

You can now specify which tags you want to allow CDATA for, and we fixed a unicode issue.

For more details see the release notes.

August 24th 2015: HtmlCleaner 2.14 released!

A number of improvements to the cleaning algorithm, plus some bug fixes around new HTML 5 tags.

For more details see the release notes.

July 1st 2015: HtmlCleaner 2.13 released!

Maintenance release fixing some recursion issues.

For more details see the release notes.

May 15th 2015: HtmlCleaner 2.12 released!

Maintenance release to fix an issue with option tags.

For more details see the release notes.

May 12th 2015: HtmlCleaner 2.11 released!

Adds much better HTML5 support, pipelining of HTML from stdin (and XML to stdout), and more

For more details see the release notes.

October 31st 2014: HtmlCleaner 2.10 released!

Various small bug fixes

For more details see the release notes.

How does it work?

Here is a typical example - improperly structured HTML containing unclosed tags and missing quotes: