Skip to content

CLI

The Defuddle.Cli package is a .NET tool with the defuddle command. It ports the parse command of upstream’s CLI, with the same options, output formats, error messages, and exit codes.

The tool needs the .NET 10 runtime.

Terminal window
dotnet tool install -g Defuddle.Cli

The source is a file path, a URL, or HTML on standard input. A source that starts with http:// or https:// is a URL.

Terminal window
# Parse a local HTML file
defuddle parse page.html
# Parse a URL
defuddle parse https://example.com/article
# Parse HTML from stdin as Markdown
curl -L https://stephango.com/saw | defuddle parse --markdown
# Output as JSON with metadata
defuddle parse page.html --json
# Prepend YAML frontmatter to the Markdown
defuddle parse page.html --markdown --frontmatter
# Extract a specific property
defuddle parse page.html --property title
# Save the output to a file
defuddle parse page.html --markdown --output article.md
# Use a custom User-Agent (helps with sites that return 403 to the default one)
defuddle parse https://example.com/article --user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)"

When there is no source argument, defuddle parse reads HTML from standard input. You can also pass -.

Option Alias Description
--output <file> -o Write the output to a file instead of standard output.
--markdown -m Convert the content to Markdown.
--md Alias for --markdown.
--json -j Output JSON with metadata and content.
--frontmatter -f Prepend YAML frontmatter, such as title, author, and source, to the output.
--property <name> -p Print one property, such as title, description, or domain.
--debug Enable debug mode.
--lang <code> -l Preferred language (BCP 47, such as en, fr, or ja).
--user-agent <string> -u Custom User-Agent header for HTTP requests.

defuddle --help, defuddle parse --help, and defuddle --version (-V) print the help and the version.

By default the output is the cleaned HTML of the main content, or Markdown with --markdown.

--json prints an object with content, title, description, domain, favicon, image, language, metaTags, parseTime, published, author, site, schemaOrgData, and wordCount. It adds contentMarkdown when --markdown is not set, and variables when a site extractor provides them. With --markdown, content holds the Markdown.

--property takes the same names, and extractorType. It takes precedence over --json. --frontmatter has no effect with --json or --property.

For a URL source, the tool downloads the page itself:

  • The request has a 10 second timeout. The page must be text/html or application/xhtml+xml, and at most 5 MB.
  • The character set comes from the Content-Type header, then from the meta tags, and then from the bytes.
  • The default User-Agent is Mozilla/5.0 (compatible; Defuddle/1.0; +https://defuddle.md). For github.com it ends in bot.
  • When the page has no content, the tool downloads it again with the bot User-Agent, unless you set --user-agent.
  • --lang sets the Accept-Language header.

The tool reads HTTPS_PROXY (for https URLs), HTTP_PROXY, and ALL_PROXY, also in lower case, in that order. NO_PROXY is a comma-separated list of hosts that skip the proxy. A name also matches its subdomains, and * matches every host. A proxy URL without a port, or with the default port of its scheme, uses port 8080. The system proxy settings are not read.

These variables apply to the download of the page. Requests that site extractors make use the default HttpClient of .NET.

The help layout, the commander error messages and the file error messages match upstream’s defuddle 0.19.13 CLI; they were compared side by side with commander 12.1. Two differences are on purpose:

  • --version prints the version of this .NET package, not the upstream version.
  • Node’s fetch sends Accept-Language: * when --lang is not set. The .NET HttpClient sends no Accept-Language header.

The exit code is 0 on success and 1 on any error. Errors are written to standard error:

Error: No content could be extracted from stdin
Error: Failed to fetch: 404 Not Found
Error: Not an HTML page (content-type: application/pdf)
Error: Page too large (7MB, max 5MB)
Error: Timed out fetching page after 10s
Error: Property "nope" not found in response

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