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

@sembl/source-html

v0.5.0

Published

Turn an HTML page into readable text for SEMBL: JSON-LD and meta tags first, boilerplate stripped.

Readme

@sembl/source-html

Turn an HTML page into text SEMBL can extract from. Zero dependencies.

pnpm add @sembl/source-html
import { coerce } from "@sembl/core";
import { htmlSource } from "@sembl/source-html";

const html = await (await fetch(url)).text();
const listing = await coerce<Listing>(htmlSource(html, "Airbnb listing"), {
  provider,
  schema,
  maxInputChars: 40_000,
});

htmlSources(html, label) returns the same content as two labelled sources — the structured data and the readable text — so that SEMBL's budget, which cuts long sources first, can never truncate the JSON-LD away however large the page. extractImages(html, { baseUrl }) returns the page's images for a gallery: OpenGraph and Twitter card images first, then JSON-LD image values, then <img> tags including lazy-loaded ones and the widest srcset candidate, with tracking pixels, icons, logos, sprites and data: URIs dropped and duplicates folded.

htmlSource renders the page in three sections, in this order:

  1. Page metadata — the <title> and every <meta> tag keyed by property or name (OpenGraph, Twitter cards, description, …).
  2. Structured data — each <script type="application/ld+json"> block that parses, as compact JSON.
  3. Page text — the body with scripts, styles, comments and the head removed, block elements as line breaks, list items bulleted, entities decoded and whitespace collapsed.

Structured data goes first on purpose: SEMBL's default truncation keeps the head of a source, so when a page blows the input budget the cleanest facts on it are the ones that survive.

The pieces are exported on their own — pageToText, htmlToText, extractJsonLd, extractMeta, decodeEntities — and preprocessHtml() returns a preprocess hook for when the sources are pages but you would rather keep fetching and coercion apart:

await coerce(pages, { provider, schema, preprocess: preprocessHtml() });

The conversion is regex-based rather than a full parser, so malformed markup degrades to slightly worse text instead of an error — the right trade for scraped input. It makes no network requests; fetching is yours.