Quickstart
Defuddle takes the HTML of a page, finds the main content, and returns cleaned HTML or Markdown together with the page’s metadata. This package is an unofficial community port of defuddle.
Install
Section titled “Install”The package targets net10.0 and netstandard2.0.
dotnet add package DefuddleParse HTML
Section titled “Parse HTML”DefuddleParser.ParseHtml takes an HTML string. Set Url to the address of the page: it is used to resolve links, to fill Domain, and to pick a site extractor. Without it, relative links stay as written.
var result = DefuddleParser.ParseHtml( html, new DefuddleOptions { Url = "https://example.com/blog/tide-pools" });
Console.WriteLine(result.Content);Read the metadata
Section titled “Read the metadata”The same response carries the metadata of the page. See Response and metadata.
Console.WriteLine(result.Title);Console.WriteLine(result.Author);Console.WriteLine(result.Description);Console.WriteLine(result.Domain);Console.WriteLine(result.Language);Console.WriteLine(result.WordCount);Get Markdown
Section titled “Get Markdown”Set Markdown to get Markdown in Content. Set SeparateMarkdown to keep the HTML in Content and get Markdown in ContentMarkdown. See Markdown.
var result = DefuddleParser.ParseHtml( html, new DefuddleOptions { Url = "https://example.com/blog/tide-pools", Markdown = true });
Console.WriteLine(result.Content); // MarkdownParse an AngleSharp document
Section titled “Parse an AngleSharp document”If you already have an AngleSharp IDocument, pass it to the DefuddleParser constructor. Parsing does not change your document.
var context = BrowsingContext.New(Configuration.Default);var document = await context.OpenAsync(request => request.Content(html).Address("https://example.com/blog/tide-pools"));
var parser = new DefuddleParser( document, new DefuddleOptions { Url = "https://example.com/blog/tide-pools" });var result = parser.Parse();
Console.WriteLine(result.Title);Console.WriteLine(result.Content);Parse returns HTML. ParseAsync and the static helpers also apply the Markdown and SeparateMarkdown options.
Parse a URL
Section titled “Parse a URL”The library parses HTML, so download the page first. ParseHtmlAsync lets a site extractor fetch more data when it needs to, through the HttpClient you pass.
using var http = new HttpClient();var html = await http.GetStringAsync(url);
var result = await DefuddleParser.ParseHtmlAsync( html, new DefuddleOptions { Url = url, Markdown = true, HttpClient = http, });
Console.WriteLine(result.Title);Console.WriteLine(result.Content);The CLI does the download for you.
MIT · Copyright 2025 Steph Ango (@kepano) · unofficial community port of defuddle