Html Agility Pack (HAP) is a free, open-source .NET code library for parsing real-world, malformed HTML into a read/write DOM, with plain XPATH and XSLT support.
What is Html Agility Pack?
Html Agility Pack is a .NET code library that reads HTML files or streams and exposes them as a read/write DOM, similar to the System.Xml object model but designed for HTML. It accepts malformed, "out of the web" HTML that strict XML parsers reject, and lets .NET developers query and manipulate it with XPATH or XSLT. The library is written in C#, maintained by ZZZ Projects, and distributed as a NuGet package with over 2,800 GitHub stars according to the repository metadata.
Key Features
- Read/write DOM — Parses HTML from files or streams into an in-memory document object model that can be both queried and modified.
- Plain XPATH and XSLT support — Use XPATH expressions or XSLT stylesheets to select nodes or transform documents, without needing to master either syntax.
- Malformed HTML tolerance — Handles broken, real-world HTML such as unclosed tags, mixed case, and invalid attributes, which would cause strict parsers to fail.
- System.Xml-like API — Mirrors the familiar System.Xml object model (nodes, attributes, navigation), making adoption straightforward for .NET developers.
- NuGet distribution — Install via Package Manager with
Install-Package HtmlAgilityPackor the .NET CLI withdotnet add package HtmlAgilityPack. - Open-source sponsorship — Free and open source, maintained by ZZZ Projects with sponsorship from Entity Framework Extensions and Dapper Plus.
Who is it for?
- .NET developers building applications that need to fetch and parse HTML from websites or local files without a browser engine.
- Web scraping projects that require extracting data from pages that are not valid XML and would break conventional XML parsers.
- Testers and QA engineers who need to inspect or normalize HTML output from their own applications in unit or integration tests.
- Tooling creators who build static analysis, link checkers, or content converters that must operate on HTML in a robust way.
FAQ
Is Html Agility Pack free?
Yes, Html Agility Pack is free and open source. The project is sponsored by ZZZ Projects, which sells commercial libraries like Entity Framework Extensions and Dapper Plus to fund development, but the parser itself has no license fee.
How do I install Html Agility Pack?
You can install it via NuGet. In the Visual Studio Package Manager Console run Install-Package HtmlAgilityPack, or in a .NET project run dotnet add package HtmlAgilityPack.
What does Html Agility Pack do?
It parses HTML from a file, string, or stream into a DOM, then lets you navigate, query, and edit it using XPATH or XSLT. Because it tolerates malformed HTML, it is suited for scraping real-world web pages.
Does Html Agility Pack support XPATH?
Yes, the library supports plain XPATH queries on the parsed HTML DOM. It also supports XSLT for transforming documents, so you can query or reshape HTML without writing the parser logic yourself.
Is Html Agility Pack a .NET framework library?
It is a .NET code library written in C#, distributed as a NuGet package. The repository page does not enumerate specific target frameworks, but the package is available through the standard NuGet gallery.








