Skip to content

Embedding in your project

This page is for projects that ship webforai to their own users: a library, a CLI, an agent framework, a Worker. It lists what webforai adds to their install and bundle, and where it runs.

npm i webforai
import { htmlToMarkdown } from "webforai";
 
const markdown = htmlToMarkdown(html, { url });

Depend on webforai, not on webforai-cli: the CLI package only adds the webforai command and its terminal dependencies.

Install footprint

The library has no CLI dependencies and no required browser driver. Its runtime dependencies are the unified syntax-tree utilities it is built on (hast-util-*, mdast-util-*, parse5), plus mathml-to-latex, trim-trailing-lines and unist-util-filter.

npm i webforai into an empty projectpackages addednode_modules
v4 (CLI included, playwright-core auto-installed)12531 MB
v510014 MB

Measured with npm 11 on 2026-10-09; of the 14 MB, webforai itself is 3.1 MB (1.4 MB of it type declarations) and nothing else is over 1 MB. pnpm gives the same result.

Optional peer dependencies

Browser drivers are optional peers, imported only by their own loader subpath. Installing webforai never installs them; if your project uses a loader, add its driver to your own dependencies.

ImportRuns inYour project adds
webforaiNode.js, Workers, browsersnothing
webforai/platformanywhere with fetchnothing
webforai/loaders/fetchanywhere with fetchnothing
webforai/loaders/playwrightNode.jsplaywright-core
webforai/loaders/puppeteerNode.jspuppeteer
webforai/loaders/cf-puppeteerCloudflare Workers@cloudflare/puppeteer (needs the nodejs_compat flag)

Runtimes

webforai, webforai/platform and webforai/loaders/fetch use no Node.js built-ins, process or Buffer.

  • Node.js — ESM (import) and CommonJS (require) builds, with TypeScript declarations for both, selected through the package's exports.
  • Cloudflare Workers — runs without the nodejs_compat flag. A Worker that converts pages with htmlToMarkdown and loaders/fetch uploads about 1.4 MB (375 KB gzipped) with Wrangler's defaults, 830 KB (300 KB gzipped) with --minify.
  • Browsers — bundles with esbuild, Vite or any bundler that honours the browser export condition, with no Node polyfills. The browser build decodes HTML entities through the DOM, so run it in a real browser rather than a Node script.

Bundle size

Minified sizes of an esbuild browser bundle (esbuild 0.19, --platform=browser --minify):

What you importMinifiedgzip
htmlToMarkdown from webforai784 KB285 KB
createPlatformClient from webforai/platform4 KB2 KB
loadHtml from webforai/loaders/fetch1 KB1 KB

About 200 KB of the conversion bundle is the weights of the built-in learned extractor (kiwame); parse5, mathml-to-latex and its XML parser make up most of the rest. webforai/platform and webforai/loaders/fetch do not pull in the converter, so a project that only calls the hosted platform stays small.

Versioning

webforai follows semver: depend on "webforai": "^5.0.0". Breaking changes ship in a major release and are listed in the CHANGELOG. Conversion output can improve in minor and patch releases (better extraction, cleaner Markdown); pin an exact version if your tests compare Markdown byte for byte.