Getting Started
Overview
Welcome to webforai, an library designed to convert HTML to Markdown with simple utilities. Whether you're working in a browser, Node.js, or even on Cloudflare Workers, webforai is your go-to tool for bridging between web and LLMs.
Installation
npm i webforaiQuick Start (CLI)
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@latest https://www.npmjs.com/package/webforai
# write to a file / emit machine-readable JSON instead
$ npx webforai@latest https://www.npmjs.com/package/webforai -o webforai.md
$ npx webforai@latest https://example.com --json | jq -r .markdownPrefer prompts? npx webforai@latest -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.
Quick 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); 
