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
-
Bounded Streaming & Direct Node Entrypoint (
39.8 MBPeak RAM): Launching directly viaCMD ["node", "--max-old-space-size=88", "dist/main.js"], streaming response bodies with a750 KBbyte 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 MBaverage). -
Automatic
/llms.txt&/llms-full.txtDiscovery (With Soft-404 Protection): Each unique origin is probed once per run for/llms.txtand/llms-full.txt. Because many SPAs return HTTP200 OKwithtext/htmlfallback pages for missing files, the parser explicitly rejectstext/htmlpayloads and HTML doctypes, then extractsllmstxt.orgsections, structured links, and bounded/llms-full.txtword/token estimates. -
Surgical Boilerplate Stripping + Clean GFM Conversion:
Before walking the DOM, we extract
title,description,canonicalUrl,language,publishedAt(OpenGraph, meta tags, JSON-LDdatePublished,<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. -
Fair Pay-Per-Event Charging:
Successful Markdown extractions (
ok: true) emitpage-extracted($0.001), while404s, 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.621scrawl & extraction time) -
Peak Container RAM:
39.8 MB(22.8 MBaverage) -
Extracted:
9,055words (25,062estimated tokens) across 5 pages, plus/llms.txt+/llms-full.txtparsed on all 3 documentation domains -
Compute Units:
0.0001031 CU(~0.0206 CU / 1,000 pages,$0.0001536platform 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
}'
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.