Dev.to AI ๐Ÿค– Ai ๐Ÿ‘ 0 ๐Ÿ“– 2 min read

Building a 40 MB RAM Web-to-Markdown Crawler in Pure Node.js (0.62s for 5 Sites, Auto /llms.txt Parsing, Zero Browsers)

Most web-to-Markdown scrapers for RAG and AI agents boot an entire headless Chromium process just to read static documentation pages, marketing sites, and blog articles. That adds 3โ€“5 seconds of cold-start latency, 400+

Most web-to-Markdown scrapers for RAG and AI agents boot an entire headless Chromium process just to read static documentation pages, marketing sites, and blog articles. That adds 3โ€“5 seconds of cold-start latency, 400+ MB of container RAM, and extra compute costsโ€”even when 90% of target pages serve complete HTML over a plain HTTP GET.

We built an open-source TypeScript + Cheerio Apify Actor (GitHub | Apify Store) that converts single URLs, batches, same-domain trees, and XML sitemaps into clean RAG-ready Markdown inside a 128 MB RAM container at $1.00 / 1,000 extracted pages.

Key Engineering Decisions

  1. Bounded Streaming & Direct Node Entrypoint (39.8 MB Peak RAM): Launching directly via CMD ["node", "--max-old-space-size=88", "dist/main.js"], streaming response bodies with a 750 KB byte cap, immediately cancelling non-HTML streams (application/pdf, images, binary assets), and discarding raw HTML strings right after DOM conversion kept live cloud peak RAM at 39.8 MB (22.8 MB average).
  2. Automatic /llms.txt & /llms-full.txt Discovery (With Soft-404 Protection): Each unique origin is probed once per run for /llms.txt and /llms-full.txt. Because many SPAs return HTTP 200 OK with text/html fallback pages for missing files, the parser explicitly rejects text/html payloads and HTML doctypes, then extracts llmstxt.org sections, structured links, and bounded /llms-full.txt word/token estimates.
  3. Surgical Boilerplate Stripping + Clean GFM Conversion: Before walking the DOM, we extract title, description, canonicalUrl, language, publishedAt (OpenGraph, meta tags, JSON-LD datePublished, <time>), author, and deduplicated internal/external links. Then we target <main> / <article>, strip <nav>, <footer>, cookie banners, ads, zero-width heading anchors, and <button>Copy</button> labels inside <pre> blocks while preserving fenced code block languages from parent VitePress/Docusaurus wrappers (language-ts, language-sh), GFM pipe tables, nested lists, and absolute-resolved URLs.
  4. Fair Pay-Per-Event Charging: Successful Markdown extractions (ok: true) emit page-extracted ($0.001), while 404s, timeouts, and skipped non-HTML files are still logged in the dataset at $0.00 charge.

Verified Live Apify Cloud Benchmark (128 MB RAM)

Across 5 real sites (docs.apify.com/academy, modelcontextprotocol.io/introduction, hono.dev/docs/, simonwillison.net/, and en.wikipedia.org/wiki/Model_Context_Protocol):

  • Total Run Time: 2.97s (0.621s crawl & extraction time)
  • Peak Container RAM: 39.8 MB (22.8 MB average)
  • Extracted: 9,055 words (25,062 estimated tokens) across 5 pages, plus /llms.txt + /llms-full.txt parsed on all 3 documentation domains
  • Compute Units: 0.0001031 CU (~0.0206 CU / 1,000 pages, $0.0001536 platform cost)

Use as a Hosted Streamable HTTP MCP Server

{
  "mcpServers": {
    "apify-markdown-crawler": {
      "url": "https://mcp.apify.com/?actors=deliberate_gratitude_shj/fast-http-markdown-crawler",
      "headers": {
        "Authorization": "Bearer <YOUR_APIFY_TOKEN>"
      }
    }
  }
}

Run via API / n8n (n8n_workflow.json included)

curl -X POST "https://api.apify.com/v2/acts/deliberate_gratitude_shj~fast-http-markdown-crawler/run-sync-get-dataset-items?token=<YOUR_APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://hono.dev/docs/",
    "detectLlmsTxt": true,
    "stripBoilerplate": true
  }'
๐Ÿ“ฐ Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ€” full credit and traffic to the original publisher.