| name | defuddle |
| description | Guide for extracting main content from web pages using defuddle. Use when users need to convert web pages to clean HTML or Markdown, extract article content, or parse web content programmatically. |
Defuddle - Web Content Extraction
Overview
Defuddle extracts the main content from web pages, removing clutter like comments, sidebars, headers, footers, and other non-essential elements. It outputs clean, consistent HTML or Markdown suitable for reading, archiving, or further processing.
Key capabilities:
- Extract article content from URLs or HTML files
- Convert content to Markdown or clean HTML
- Extract metadata (title, author, description, published date, etc.)
- Available as CLI tool, Node.js library, and browser library
- Standardizes HTML elements (headings, code blocks, footnotes, math)
When to Use This Skill
Use defuddle when users ask to:
- Convert web pages to Markdown or clean HTML
- Extract article content from URLs
- Parse web content programmatically
- Remove clutter from web pages (ads, navigation, sidebars)
- Extract metadata from web pages
- Process HTML files for content extraction
Installation
npm install -g defuddle
For Node.js usage (requires JSDOM):
npm install defuddle jsdom
CLI Usage
Basic Commands
Parse a URL and output Markdown:
defuddle parse https://example.com/article
Parse a local HTML file:
defuddle parse page.html
Output Options
Output as Markdown:
defuddle parse page.html --markdown
defuddle parse page.html --md
Output as JSON with metadata:
defuddle parse page.html --json
Save output to a file:
defuddle parse page.html --output result.md
defuddle parse page.html -o result.html
Extract a specific property:
defuddle parse page.html --property title
defuddle parse page.html -p author
Enable debug mode (verbose logging):
defuddle parse page.html --debug
CLI Options Summary
| Option | Alias | Description |
|---|
--output <file> | -o | Write output to a file |
--markdown | -m, --md | Convert to Markdown |
--json | -j | Output JSON with metadata |
--property <name> | -p | Extract specific property |
--debug | | Enable debug mode |
Node.js Usage
Basic Parsing
import { JSDOM } from 'jsdom';
import { Defuddle } from 'defuddle/node';
const html = '<html><body><article>...</article></body></html>';
const result = await Defuddle(html);
const dom = await JSDOM.fromURL('https://example.com/article');
const result = await Defuddle(dom);
With Options
const url = 'https://example.com/article';
const result = await Defuddle(dom, url, {
debug: true,
markdown: true,
json: true
});
console.log(result.content);
console.log(result.title);
console.log(result.author);
Response Properties
| Property | Type | Description |
|---|
content | string | Cleaned extracted content (HTML or Markdown) |
title | string | Article title |
author | string | Author name |
description | string | Article description/summary |
published | string | Publication date |
domain | string | Domain name |
site | string | Site name |
image | string | Main article image URL |
favicon | string | Site favicon URL |
wordCount | number | Word count of content |
metaTags | object | Meta tags from page |
schemaOrgData | object | Raw schema.org data |
parseTime | number | Parsing time in milliseconds |
Configuration Options
const options = {
debug: false,
markdown: false,
separateMarkdown: false,
url: 'https://example.com',
contentSelector: 'article.main',
useAsync: true,
removeExactSelectors: true,
removePartialSelectors: true,
removeHiddenElements: true,
removeLowScoring: true,
removeSmallImages: true,
removeImages: false,
standardize: true
};
Browser Usage
import Defuddle from 'defuddle';
const defuddle = new Defuddle(document);
const result = defuddle.parse();
console.log(result.content);
console.log(result.title);
HTML Standardization
Defuddle standardizes HTML for consistent output:
Headings:
- Removes first H1/H2 if it matches the title
- Converts H1s to H2s
- Removes anchor links from headings
Code blocks:
- Removes line numbers and syntax highlighting
- Preserves language in
data-lang attribute
Footnotes:
- Converts to standard format with backrefs
Math:
- Converts MathJax/KaTeX to MathML
Debugging
Enable debug mode to get detailed extraction info:
const result = new Defuddle(document, { debug: true }).parse();
console.log(result.debug.contentSelector);
console.log(result.debug.removals);
Pipeline toggles for troubleshooting:
const result = await Defuddle(dom, url, {
removeLowScoring: false,
removeHiddenElements: false,
removeSmallImages: false
});
Quick Command Reference
CLI:
defuddle parse https://example.com/article --markdown
defuddle parse page.html --json
defuddle parse page.html --property title
defuddle parse page.html -o output.md
Node.js:
import { Defuddle } from 'defuddle/node';
const result = await Defuddle(htmlString, url, { markdown: true });
Browser:
const result = new Defuddle(document).parse();
Resources