Definition
HTML token cost is the LLM input cost of feeding raw HTML into a context window versus a cleaner format like markdown; a 60KB HTML page averages roughly 30K tokens raw versus 3K tokens as markdown, so any agent that processes web pages without an HTML to markdown step pays ~10x in input tokens.
In Depth
HTML token cost showed up as a recurring pain point in 2026 r/ClaudeAI threads. The fix is a markdown conversion step before the LLM sees the page: PullMD (OSS, self-hosted), Scavio's /extract endpoint (hosted, $0.0043/extract), or Firecrawl's scrape mode (per-credit, scales). The math behind the 10x: HTML averages 5-10 boilerplate bytes per content byte (script tags, inline CSS, navigation, footer, ad markup), and tokenizers count each separately. Stripping to semantic content with markdown headers and links keeps the LLM context focused. Honest constraint: token cost is only one half of the equation; if the agent needs to interact with the page (click, form-fill), markdown loses the interaction surface and a real browser is required.
Example Usage
Switching the Claude Code agent's web-fetch tool from raw HTML to Scavio /extract markdown cut average task input tokens from ~30K to ~3K, dropping per-task LLM cost by an order of magnitude.
Platforms
HTML Token Cost is relevant across the following platforms, all accessible through Scavio's unified API:
Related Terms
Multi-Platform Search API
A multi-platform search API is a single REST endpoint that returns structured JSON from several public surfaces — Google...
Structured Search Output
Structured search output is the typed JSON returned by a search API — title, snippet, link, position, timestamp — that f...
Agent Architecture
Agent architecture is the set of design choices that turn an LLM prompt into a production system: routing and classifica...