+15
日增长
10,043
stars
475
forks
20
watchers
227
prs
255
issues
47
releases
README
de·fud·dle /diˈfʌdl/ transitive verb
to remove unnecessary elements from a web page, and make it easily readable.
Beware! Defuddle is very much a work in progress!
Defuddle extracts the main content from web pages. It cleans up web pages by removing clutter like comments, sidebars, headers, footers, and other non-essential elements, leaving only the primary content.
Overview
Defuddle takes a URL or HTML, finds the main content, and returns cleaned HTML or Markdown. Defuddle was created for the browser extension Obsidian Web Clipper, but it is designed to run in any environment.
Defuddle can be used as a replacement for Mozilla Readability with a few differences:
- More forgiving, removes fewer uncertain elements.
- Provides a consistent output for footnotes, math, code blocks, etc.
- Uses a page's mobile styles to guess at unnecessary elements.
- Extracts more metadata from the page, including schema.org data.
Usage
Browser
javascript
import Defuddle from 'defuddle';
// Parse the current document
const defuddle = new Defuddle(document);
const result = defuddle.parse();
// Access the content and metadata
console.log(result.content);
console.log(result.title);
console.log(result.author);
Node.js
defuddle/node accepts a DOM Document from any implementation (JSDOM, linkedom, happy-dom, etc.).
javascript
import { parseHTML } from 'linkedom';
import { Defuddle } from 'defuddle/node';
const { document } = parseHTML(html);
const result = await Defuddle(document, 'https://example.com/article', {
markdown: true
});
console.log(result.content);
console.log(result.title);
console.log(result.author);
Or with JSDOM:
javascript
import { JSDOM } from 'jsdom';
import { Defuddle } from 'defuddle/node';
const dom = new JSDOM(html, { url: 'https://example.com/article' });
const result = await Defuddle(dom.window.document, 'https://example.com/article');
_Note: for defuddle/node to import properly, the module format in your package.json has to be set to { "type": "module" }_
CLI
Defuddle includes a command-line interface for parsing web pages directly from the terminal. You can run it with npx or install it globally. The CLI accepts a file path, a URL, or HTML piped over stdin.
bash
Parse a local HTML file
npx defuddle parse page.html
Parse a URL
npx defuddle parse https://example.com/article
Parse HTML from stdin
cat page.html | npx defuddle parse
Parse fetched HTML from stdin as markdown
curl -L https://stephango.com/saw | npx defuddle parse --markdown
Output as markdown
npx defuddle parse page.html --markdown
Output as JSON with metadata
npx defuddle parse page.html --json
Extract a specific property
npx defuddle parse page.html --property title
Save output to a file
npx defuddle parse page.html --output result.html
Enable debug mode
npx defuddle parse page.html --debug
Use a custom User-Agent (helps with sites that return 403 to the default UA)
npx defuddle parse https://example.com/article --user-agent "MozTop issues
#375Projectorjunkies missing data11 comments · 2026-09-05#262Add Homebrew formula5 comments · 2026-04-21#283Extraction fails for frontend-heavy Angular SPA HTML with large inline style/font blocks4 comments · 2026-05-08#231Support downloading linked images and rewriting Markdown image paths to local files4 comments · 2026-04-08#395Defuddle loses table headings and adjacent images on Quarto-generated pages3 comments · 2026-09-25#273Add extractor for Xiaohongshu (rednote) pages3 comments · 2026-04-29#257Broken content capture on bioRxiv3 comments · 2026-04-15#30Missing images on figure tag3 comments · 2025-04-07
Latest release
0.19.6 0.19.6 2026-10-24- Fixed HTML kept in Markdown output (embeds, SVG, superscripts, and complex tables) carrying unsafe links and event handlers, or Markdown that renders as links, including when calling createMarkdownContent directly. - Fixed YouTube auto-dub captions being selected instead of the default audio language when the player response omits the default caption index (410). - Fixed YouTube transcripts using stale inline player data from another video when caption requests fail (400). - Updated development dependencies with security fixes.