HTML to Markdown —
drop token count by up to 85%
Send raw HTML to LeanTokn, get back clean Markdown. Fewer tokens, same meaning. Works with GPT-4, Claude, Gemini, Llama — any LLM that reads text.
Paste any HTML. See the Markdown.
Tokens are money. HTML wastes most of them.
A typical web page carries navigation bars, nested divs, inline styles, data attributes, and scripts — none of which a language model uses. HTML often carries 6–10× more tokens than the same content in Markdown.
LeanTokn preserves every heading, paragraph, list, table, link, and code block. Your model reads the same information. You pay for 15% of the tokens.
No library to install. No parsing logic to maintain. One HTTP POST before you embed or prompt. Works in every language and every runtime.
Built for developers who feed the web to LLMs
Scrape, trim, embed. Smaller chunks → better retrieval.
Trim search results before passing to your agent.
Index HTML docs as Markdown for cleaner context.
Trim article HTML before sending to a summariser.
Trim scraped product pages for shopping assistants.
Clean structured content from messy HTML before parsing.
Drop-in. Any language.
Real-world token savings
Measured on real pages using cl100k_base tokenisation — the same encoding GPT-4 and Claude use.
Common questions
html2text and pandoc are local libraries — they require installation, maintenance, and produce inconsistent output across versions. LeanTokn is a hosted API: one HTTP call, no dependencies, consistent output. It also returns exact token counts using the same tokenizer models use (cl100k_base), so you know precisely how much context you saved.
Yes. LeanTokn preserves the semantic structure of your HTML — headings, links, ordered and unordered lists, tables, blockquotes, inline code, and fenced code blocks. Navigation bars, ads, scripts, style tags, and boilerplate are stripped.
Any language that can make an HTTP POST request works. See the code examples above for Python and Node.js. For Go, Ruby, PHP, or any other language, POST to /v1/trim with your API key in the Authorization header and body { "prompt": "<html>", "type": "html" }.
Yes. All accounts include 1 million tokens saved per month on low-intensity calls at no charge. HTML→Markdown conversion is a low-intensity operation. No credit card required to start.
The API accepts up to 1 MB per request. Most web pages are well under this limit. For very large pages with embedded base64 images, strip the <img src="data:..."> tags before sending.
Yes — there is no per-account concurrency limit. Fire as many requests as you need simultaneously. Typical RAG ingestion pipelines process thousands of pages per minute.
Similar outcome, very different workflow. LeanTokn is infrastructure — call it from your pipeline and get back Markdown plus exact token counts. No dependencies to install, no library version drift, works identically across every language and environment.
Start saving tokens today
1 million tokens free every month. No credit card required.