fundamentals

Cloudflare — Markdown for Agents

If your site sits behind Cloudflare, flipping this one toggle negotiates Markdown at the edge with no origin changes required.

If your site is proxied through Cloudflare, you may not need to implement content negotiation at the origin at all.

Markdown for Agents is a managed Cloudflare feature that:

  • Detects Accept: text/markdown at the edge
  • Fetches your HTML from the origin
  • Converts it to clean Markdown on the fly
  • Returns the Markdown with correct Content-Type and Vary: Accept
  • Caches the two representations separately at the edge

If Cloudflare is already in front of your site, this can be enabled without origin code changes.

How to enable it

  1. Cloudflare dashboard → your domain
  2. Rules → Settings (or search “Markdown for Agents”)
  3. Flip the toggle to On

Cloudflare’s documentation →

What it does

Internally, Cloudflare:

  • Reads Accept from the incoming request
  • If the primary type preference is text/markdown, routes the request through their HTML-to-Markdown converter before responding
  • Sets Content-Type: text/markdown; charset=utf-8 and Vary: Accept
  • Uses the same edge cache keyed on Accept so HTML and Markdown are cached separately

When this is the right call

  • You want the benefit (agents getting Markdown) with zero code.
  • Your site is already on Cloudflare.
  • The default conversion is good enough — it handles most article-style content well, reasonable tables, code blocks, lists, links.

When you’d still negotiate at the origin

  • You want control over exactly what Markdown looks like (e.g. preserving front-matter, custom admonitions, specific heading levels).
  • Your source of truth is already Markdown (CMS, MDX) and round-tripping through HTML-to-Markdown loses fidelity.
  • You’re not on Cloudflare.

Even if you enable Markdown for Agents today, origin-side negotiation stays as a fallback and a migration path.

Verify it

Same test as any other content-negotiation setup:

curl -sI -H "Accept: text/markdown" https://yoursite.com/article

You should see Content-Type: text/markdown and Vary: Accept from Cloudflare, even though your origin didn’t change anything.