Skip to content

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.

The package targets net10.0 and netstandard2.0.

Terminal window
dotnet add package Defuddle

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);

snippet source | anchor

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);

snippet source | anchor

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); // Markdown

snippet source | anchor

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);

snippet source | anchor

Parse returns HTML. ParseAsync and the static helpers also apply the Markdown and SeparateMarkdown options.

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);

snippet source | anchor

The CLI does the download for you.

MIT · Copyright 2025 Steph Ango (@kepano) · unofficial community port of defuddle