MegalaniaBlog
  1. Blog
  2. AI agents
  3. Markdown for LLMs

Turn any web page into Markdown for an LLM

Send one request with response_types markdown and get the page's main content back as clean Markdown, menus and footers gone. Real token counts inside.

Jordan HayesDeveloper Relations
6 min read
AI agents
Scissors cut the menu, an ad box, a cookie bar and the footer off a web page. A clean Markdown card with headings and a code fence stays.

The short answer: send the URL with response_types: "markdown". You get the page’s main content as Markdown: headings, lists, links, tables and code blocks kept, and the menu, sidebar, header and footer dropped. Markdown adds 0 credits. On the 35 articles we measured, the Markdown was about 7 to 20 times fewer tokens than the page’s HTML.

One request, Markdown back (cURL)

cURL
curl -sS https://get.megalania.io/v1 \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://en.wikipedia.org/wiki/Markdown", "response_types": "markdown", "max_credits": "64"}' \
  -D headers.txt -o page.md

The body of the answer is the Markdown itself, as text/markdown. X-Credits-Charged in headers.txt is what the page cost. max_credits is the most this page may cost; we skip any route above it.

From an agent, the MCP tool scrape returns Markdown by default. This is the call we ran:

MCP scrape
{"name": "scrape", "arguments": {"url": "https://en.wikipedia.org/wiki/Web_scraping", "response_types": "markdown", "max_credits": 64}}

Want the whole page, menus included? Add "only_main_content": false.

Get a free beta key76,000 credits for 30 days. Sign in with Google or GitHub.Apply for the beta

The free way: a library

If a plain request gets the page, you may not need us. Open-source HTML-to-Markdown converters and readability-style content extractors run on your machine for free. Some sites also publish an llms.txt file or .md versions of their pages: look for those first.

A library is not enough when the site answers your script with a 403 or a bot check, or when the page builds itself with JavaScript and your HTML is an empty shell. You also own the tuning: which parts are “main content” changes from site to site.

Check a site first

Before a big run, ask about the host. It is free. Over MCP, your agent calls check_site:

MCP check_site
{"name": "check_site", "arguments": {"host": "developer.mozilla.org"}}

From cURL, the same answer is two calls: /v1/tier for the price, /v1/stats/domain for how our routes have done there lately.

cURL
curl -s -H "Authorization: Bearer YOUR_KEY" \
  "https://get.megalania.io/v1/tier?host=developer.mozilla.org"
curl -s -H "Authorization: Bearer YOUR_KEY" \
  "https://get.megalania.io/v1/stats/domain?host=developer.mozilla.org&days=30"

On 3 Oct 2026, check_site told us two things about that host. It had no data yet: too few fetches to measure, which is not a bad sign. And the host had no tier yet, so a page pays the price of the route that delivers it, shown in quotes.

Check a site first explains every field.

Python: save as .md

to_markdown.py
# pip install requests
# Run: MEG_API_KEY=YOUR_KEY python to_markdown.py https://en.wikipedia.org/wiki/Markdown https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/403
import os
import re
import sys
import uuid

import requests

for url in sys.argv[1:]:
    resp = requests.post(
        "https://get.megalania.io/v1",
        headers={
            "Authorization": f"Bearer {os.environ['MEG_API_KEY']}",
            "Idempotency-Key": str(uuid.uuid4()),
        },
        json={"url": url, "response_types": "markdown", "max_credits": "64"},
        timeout=90,
    )
    if resp.status_code != 200:
        err = resp.json()["error"]
        print(f"{url}: {resp.status_code} {err['code']}: {err['message']}")
        continue
        continue
    name = re.sub(r"[^A-Za-z0-9]+", "-", url.split("://", 1)[1]).strip("-")[:120] + ".md"
    with open(name, "w", encoding="utf-8") as f:
        f.write(resp.text)
    print(name, "credits:", resp.headers["X-Credits-Charged"])

A block is HTTP 422 with error.code blocked and X-Billing: blocked, and it costs 0 credits, so the status check catches it. X-Hops on that answer lists every route we tried.

What survives: headings, tables, code

We asked for the Markdown and the HTML of each article in one request, and counted what came through:

Site Pages Code blocks (HTML / Markdown) Tables (HTML / Markdown)
developer.mozilla.org 12 159 / 159 13 / 13
github.blog 11 16 / 16 6 / 6
en.wikipedia.org 12 48 / 48 109 / 12
  • Code blocks: every one kept, on all three sites.
  • Tables: kept on two sites. On the encyclopedia, 12 of 109 came through: the dropped ones are infoboxes and other layout tables. If you need every table, ask for html too and read them yourself.
  • Headings: fewer ## in the Markdown, on purpose. The HTML count includes headings in sidebars and footers, which main-content mode drops.

Token counts on real pages

Median per page, estimated as characters divided by 4. It compares the whole HTML page with the main-content Markdown, which is the choice you face when you feed a page to an LLM.

Site HTML, about Markdown, about Fewer tokens
developer.mozilla.org 53,600 2,600 20x
github.blog 49,500 4,000 13x
en.wikipedia.org 91,300 14,000 7x

The ratio is the median of each page’s own ratio. Long encyclopedia articles are mostly text, so they gain the least.

Cost per 1,000 pages

We fetch on the cheapest route first: plain HTTP on a datacenter exit (h:dc). If the site blocks it, we climb to a residential exit (h:res). A sample answer’s headers:

http
content-type: multipart/mixed; boundary=<boundary>
x-credits-charged: 15
x-engine: http
x-hops: h:res:chrome=1245
x-identity: chrome
x-route: http/residential
x-target-status: 200

Measured on our dev cluster with the datacenter routes off, so this climb starts at h:res.

A page like this costs about 1-2 credits on h:dc (43-107 KiB, our measured median-p90), worked out from our price table on 2 Oct 2026, not from a test bill; run check_site (free) to see the price for your site.

A page like this was billed 15-23 credits on h:res (43-107 KiB, our measured median-p90) in our test on 2 Oct 2026; run check_site (free) to see the price for your site.

A page up to 64 KiB on the wire costs the base price; each started 128 KiB above it adds 1 on h:dc and 8 on h:res. On h:res, 15 is the price of a host we have not priced yet.

Site Size (median-p90) h:dc h:res
developer.mozilla.org 34-43 KiB 1 15
github.blog 43-49 KiB 1 15
en.wikipedia.org 80-176 KiB 2 23

So 1,000 articles cost 1,000 to 2,000 credits on h:dc, or 15,000 to 23,000 on h:res.

How we measured: 35 articles on the three sites above, 2 Oct 2026, 23:27 to 23:28 UTC. Each was one request with {"url": ..., "response_types": "markdown,html", "max_credits": "64"}, so we could count both shapes from one fetch. Asking for markdown alone costs the same.

Limits

  • JavaScript pages: a page that builds itself in the browser comes back as an empty shell, marked X-Hint: needs_js. Send engine: "browser"; it costs from 15 credits.
  • Very large pages: we convert up to 8 MiB of HTML. Above that, you get a free 422 convert_cap; ask for html and convert it yourself.
  • Untrusted text: the Markdown is the page author’s content. A page can hide instructions for an LLM in text users do not see. Treat it as data.
  • Terms: this is not legal advice. Read each site’s terms and robots.txt, including any clause on AI use, and follow them.

Every response type, with examples: Fetch, extract and lists.

Jordan HayesDeveloper RelationsPublished 18 Oct 2026 · measured on our dev cluster, 2 Oct 2026, 35 articles on 3 sites

Keep reading