npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

boilerstrip

v0.4.1

Published

Learn site boilerplate selectors from a page set and convert HTML to Markdown

Readme

boilerstrip

npm CI

Learn site boilerplate selectors from a set of HTML pages and convert HTML to clean Markdown with the boilerplate stripped.

Given multiple HTML pages from the same website, learn discovers which CSS selectors and HTML snippets are boilerplate (navigation, footers, cookie banners, legal disclaimers, etc.) by finding elements whose text content is stable across pages. The resulting Removals can then be fed into convert or convertMany, which strips the boilerplate and converts the remaining content to Markdown.

Install

npm install boilerstrip

Migration: v0.1 → v0.2

Breaking changes:

  • All HTML inputs are now Buffer. The previous API accepted Buffer | string; string inputs are no longer accepted and will cause a TypeScript type error. Pass Buffer.from(html, 'utf8') or read files with readFileSync (which returns Buffer by default).
  • convert now processes a single Buffer and returns a ConvertResult object (with content, title, lang, meta, link, canonicalUrl fields), not a raw Markdown string.
  • convertMany is a new batched API for converting multiple pages in one call — more efficient than calling convert in a loop.
  • Non-UTF-8 Buffer inputs (e.g. windows-1252, shift_jis) now return an explicit error rather than silently replacing invalid bytes.

Usage

import { learn, convert, convertMany } from 'boilerstrip'

// Learn boilerplate from multiple pages of the same site
const removals = await learn([page1Buffer, page2Buffer, page3Buffer])

// Convert a single page
const result = await convert(htmlBuffer, { removals })
console.log(result.content)   // Markdown string
console.log(result.title)     // <title> text

// Convert many pages in one batched call (more efficient than N convert() calls)
const results = await convertMany([html1, html2, html3], { removals })
results.forEach(r => console.log(r.content))

API

learn(pages, options?): Promise<Removals>

Analyzes an array of HTML pages from the same site and returns the discovered boilerplate selectors and snippets. Requires at least 2 pages.

  • pagesArray<Buffer> — at least 2 HTML pages to analyze
  • options — optional LearnOptions

convert(html, options?): Promise<ConvertResult>

Strips boilerplate and converts a single HTML page to Markdown.

  • htmlBuffer — HTML page to convert
  • options — optional ConvertOptions

convertMany(htmls, options?): Promise<ConvertResult[]>

Batched version of convert. Converts multiple HTML pages in a single N-API call. More efficient than calling convert in a loop when processing many pages.

  • htmlsArray<Buffer> — HTML pages to convert
  • options — optional ConvertOptions applied to all pages

ConvertResult

interface ConvertResult {
  content: string          // cleaned Markdown
  title?: string           // <title> text
  lang?: string            // <html lang="...">
  canonicalUrl?: string    // <link rel="canonical" href="...">
  meta: Record<string, string>   // <meta name/property> map
  link: Record<string, string>   // <link rel> map
}

ConvertOptions

interface ConvertOptions {
  removals?: Removals                  // from learn()
  cssSelectorsToRemove?: string[]      // additional CSS selectors to strip
  contentSelectors?: string[]          // CSS selectors for the main content root
  linkTextContentToRemove?: string[]   // remove <a>/<button> by visible text
  linkHrefsToRemove?: string[]         // remove <a> by href prefix (e.g. "javascript:")
  linkRelTokensToRemove?: string[]     // exclude <link rel="..."> from link map
  useTextDensityFilter?: boolean       // use text-density scoring to find main content
}

Removals

interface Removals {
  cssSelectorsToRemove: string[]
  htmlToRemove: string[]
}

The serializable result of learn. Can be stored and reused across runs.

LearnOptions

interface LearnOptions {
  boilerplatePatterns?: string[]       // override built-in patterns; [] disables snippet matching
  maxSelectorMatchesPerPage?: number   // default 20
  minSelectorAverageStableRatio?: number  // default 0.6
  minSelectorPerPageStableRatio?: number  // default 0.35
  minSnippetTextLength?: number        // default 40
  maxSnippetTextLength?: number        // default 240
}

License

MIT