← all repositories
harlan-zw/mdream

HTML in, Markdown out, tokens down 92%

mdream turns messy HTML into LLM-ready Markdown, fast enough that Cloudflare uses it in production.

★1k stars TypeScript Data Tooling
mdream
Collecting fresh signals — velocity needs a few days of history.
collecting data…
star history

What it does

mdream converts HTML to GitHub Flavored Markdown, tuned specifically as LLM input rather than for human prettiness. It ships as a Rust NAPI engine (with WASM for edge runtimes) plus a pure-JS engine with zero native dependencies, and it powers Cloudflare Browser Run’s /markdown and /crawl endpoints — a decent hint it holds up under real traffic.

The interesting bit

It converts as HTML streams in, and the joined output matches a one-shot conversion — so you can start feeding a crawler or LLM pipeline before the page finishes downloading. The token math is the real pitch: up to 92% fewer tokens than raw HTML on their measured pages, which directly cuts cost and context waste.

Key highlights

  • Dual engines: Rust NAPI for performance, @mdream/js for tree-shakable, dependency-free use
  • Streaming conversion with output identical to one-shot mode
  • clean mode strips tracking params, empty links, and redundant anchors
  • Ecosystem around the core: crawler for llms.txt generation, Vite plugin, GitHub Action, Docker images, and a Rust crate
  • Extraction hooks let you pull out headers or images mid-conversion

Caveats

  • The Rust engine loads native bindings, so bundlers may need it marked external (Next.js, Webpack, etc.)
  • The 92% token-reduction figure applies only to their measured pages, not a universal guarantee
  • The package sprawl (seven-plus ways to install it) takes a moment to navigate

Verdict

If you’re building anything that feeds web pages into an LLM — RAG, crawlers, agent tooling — this is squarely aimed at you. If you just want pretty Markdown for a human reader, a simpler converter will do.

Frequently asked

What is harlan-zw/mdream?
mdream turns messy HTML into LLM-ready Markdown, fast enough that Cloudflare uses it in production.
Is mdream open source?
Yes — harlan-zw/mdream is open source, released under the MIT license.
What language is mdream written in?
harlan-zw/mdream is primarily written in TypeScript.
How popular is mdream?
harlan-zw/mdream has 1k stars on GitHub.
Where can I find mdream?
harlan-zw/mdream is on GitHub at https://github.com/harlan-zw/mdream.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.