Skip to content

About

Get the main content of any page as Markdown. (port of https://github.com/kepano/defuddle)

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Defuddle for .NET

NuGet

Get the main content of any page as clean HTML or Markdown, in C#.

It is an unofficial community port of defuddle by Steph Ango (@kepano). It ports upstream 0.19.13. Defuddle finds the main content of a web page and removes clutter such as comments, sidebars, headers, and footers.

To learn more, read the documentation.

Preview the docs site locally:

cd docs-site && npm ci && npm run api && npm run dev

Open http://localhost:4321/defuddle-dotnet/ . That URL is the marketing page. Documentation starts at http://localhost:4321/defuddle-dotnet/docs/ . Article sources stay in docs/articles/. See docs-site/README.md.

Installation

The package targets net10.0 and netstandard2.0. Run dotnet add package Defuddle.

Usage

Parsing HTML

var result = DefuddleParser.ParseHtml(
    html,
    new DefuddleOptions { Url = "https://example.com/blog/tide-pools" }
);

Console.WriteLine(result.Content);

snippet source | anchor

Reading 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

See Response and metadata for every property.

Getting 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

Parsing an AngleSharp 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

Parsing a URL

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

Debugging

var result = DefuddleParser.ParseHtml(html, new DefuddleOptions { Debug = true });

if (result.Debug is { } debug)
{
    Console.WriteLine(debug.ContentSelector);
    foreach (var removal in debug.Removals)
    {
        Console.WriteLine($"{removal.Step}: {removal.Reason} {removal.Selector}");
    }
}

snippet source | anchor

See Debugging and Options.

Site extractors

Pages from sites such as GitHub, Reddit, Hacker News, YouTube, Wikipedia, and X have their own extractors, picked from the URL. See Site extractors.

CLI

dotnet tool install -g Defuddle.Cli
defuddle parse https://example.com/article --markdown
curl -L https://stephango.com/saw | defuddle parse --json

The tool needs the .NET 10 runtime. It parses a file, a URL, or HTML on standard input. See CLI for every option.

Coming from JavaScript

Migrating from upstream maps the JavaScript names to the C# ones.

Contributing

See CONTRIBUTING.md.

License

MIT. Defuddle is Copyright (c) 2025 Steph Ango (@kepano). The .NET port is Copyright (c) 2026 Darío Kondratiuk. See LICENSE and NOTICE.

About

Get the main content of any page as Markdown. (port of https://github.com/kepano/defuddle)

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages