# Getting Started

## Overview

Welcome to webforai, a 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.

## 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:

```go
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 .markdown
```

Prefer prompts? `npx webforai@latest -i` starts a guided interactive flow. The full flag reference — including JavaScript rendering via Playwright or the [hosted platform](https://webforai.dev/platform), and the Agent Skill for AI agents — lives on the [CLI page](https://webforai.dev/cli).

## Installation

To use the library, install the package:

```bash title="npm"
npm i webforai
```

## 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**.

```tsx title="fetch"
import { loadHtml } from "webforai/loaders/fetch"; 
 
// Load html from url
const url = "https://www.npmjs.com/package/webforai";
const html = await loadHtml(url); 
```

The `loadHtml` function is designed for ease of use and is not recommended for intensive use in production environments. For production crawling, use the [hosted platform](https://webforai.dev/platform), which runs the browsers, proxies and queues for you.

### Convert HTML to Markdown

Finally, convert HTML to Markdown with the `htmlToMarkdown` function.

```ts
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); 
```

- [CLI reference](https://webforai.dev/cli) — every flag, batch and crawl, JSON output
- [Loaders](https://webforai.dev/docs/loaders) — fetch, Playwright, Puppeteer and Cloudflare Browser Rendering
- [How it works](https://webforai.dev/how-it-works) — extraction and conversion
- [Hosted platform](https://webforai.dev/platform) — the API, engines and pricing
