Getting Started
Overview
webforai turns any HTML into the cleanest Markdown, for humans and AI agents, in Node.js,
Cloudflare Workers and browsers. It has two modes: reader mode (the default, preset reader)
extracts the main content of a page, like Mozilla Readability; agent mode (preset agent)
adds only the links an AI agent needs to explore the site, for about half the tokens of the whole
page. Both are measured against other converters on the benchmarks page.
Quick Start (CLI)
The CLI needs no install. Convert any URL (or local HTML file) to Markdown in one command — the Markdown is printed to stdout, so it can be piped, redirected, or captured:
npx webforai-cli https://www.npmjs.com/package/webforai
# write to a file / emit machine-readable JSON instead
npx webforai-cli https://www.npmjs.com/package/webforai -o webforai.md
npx webforai-cli https://example.com --json | jq -r .markdownPrefer prompts? npx webforai-cli -i starts a guided interactive flow. The full flag
reference — including JavaScript rendering via Playwright or the
hosted platform, and the Agent Skill for AI agents — lives on the
CLI page.
Installation
To use the library, install the package:
npm i webforaiQuick Start (Library)
Load HTML with utilities
Firstly, load HTML using the loadHtml utility. Using this function, you can get HTML from a URL in a simple way. It supports versions for fetch, Playwright, and Puppeteer.
import { loadHtml } from "webforai/loaders/fetch";
// Load html from url
const url = "https://www.npmjs.com/package/webforai";
const html = await loadHtml(url); Convert HTML to Markdown
Finally, convert HTML to Markdown with the htmlToMarkdown function.
import { htmlToMarkdown } from "webforai";
import { loadHtml } from "webforai/loaders/fetch";
// Load html from url
const url = "https://www.npmjs.com/package/webforai";
const html = await loadHtml(url);
const markdown = htmlToMarkdown(html); Next
- CLI reference — every flag, batch and crawl, JSON output
- Loaders — fetch, Playwright, Puppeteer and Cloudflare Browser Rendering
- How it works — extraction and conversion
- Hosted platform — the API, engines and pricing

