Markdown Conversion for Agents: Negotiation, Limits and APIs
How HTTP Accept negotiation serves Markdown at the edge, enable Markdown for Agents, convert files with Workers AI toMarkdown, and parse structured errors.
This page summarizes Cloudflare documentation on Markdown for Agents (automatic HTML-to-Markdown at the edge when clients send Accept: text/markdown), Workers AI Markdown Conversion (env.AI.toMarkdown() and the REST API for PDFs, images, and office files), and how Cloudflare’s own docs for agents expose Markdown. Browsers and clients that do not ask for Markdown keep receiving HTML.
Markdown for Agents: what edge conversion does
Section titled “Markdown for Agents: what edge conversion does”Markdown for Agents converts a zone’s HTML responses to Markdown at the network layer when the request negotiates text/markdown. The origin still serves HTML; Cloudflare fetches it and returns Markdown to the client.
Markdown has quickly become the lingua franca for agents and AI systems as a whole. The format’s explicit structure makes it ideal for AI processing, ultimately resulting in better results while minimizing token waste.
— Cloudflare, Markdown for Agents
When AI systems request pages from any website that uses Cloudflare and has Markdown for Agents enabled, they can express the preference for text/markdown in the request: our network will automatically and efficiently convert the HTML to markdown, when possible, on the fly.
— Cloudflare, Introducing Markdown for Agents
Conversion strips non-content markup (scripts, styles, navigation, and similar), turns interactive UI into readable structure where possible, and can attach YAML frontmatter from page meta tags plus optional JSON-LD in a fenced block. AI consumability guidance explains why HTML alone is a poor fit for agents: hidden tab panels and presentation markup waste tokens and lose meaning when naively converted.
Accept: text/markdown — how to request Markdown from a URL
Section titled “Accept: text/markdown — how to request Markdown from a URL”Clients that want Markdown instead of HTML use HTTP content negotiation on the Accept header. For pages on a zone with Markdown for Agents enabled:
curl https://developers.cloudflare.com/fundamentals/reference/markdown-for-agents/ \ -H "Accept: text/markdown"A successful response uses content-type: text/markdown; charset=utf-8, includes Vary: Accept (so caches keep HTML and Markdown variants separate), and may include a content-signal header (see below). After a streaming conversion update, converted responses no longer include Content-Length, x-markdown-tokens, or x-original-tokens; clients that plan context windows must estimate tokens themselves (more efficient Markdown for Agents conversion).
Cloudflare developer documentation: index.md and copy actions
Section titled “Cloudflare developer documentation: index.md and copy actions”On developers.cloudflare.com, every doc page can be read as Markdown without enabling the feature on your own zone:
- Append
/index.mdto the page URL (for example,https://developers.cloudflare.com/workers/get-started/index.md). - Send
Accept: text/markdownon the same URL (docs for agents). - Use the page Copy as Markdown control in the UI.
Cloudflare also publishes llms.txt and llms-full.txt catalogs for bulk or offline use (AI consumability).
Accept header negotiation: which format you get
Section titled “Accept header negotiation: which format you get”For structured error responses (including 1xxx errors), Cloudflare documents this precedence (error responses):
| Request header sent | Response format |
|---|---|
Accept: application/json |
JSON |
Accept: application/problem+json |
JSON (application/problem+json) |
Accept: application/json, text/markdown;q=0.9 |
JSON (higher q) |
Accept: text/markdown |
Markdown |
Accept: text/markdown, application/json |
Markdown (equal q, first-listed wins) |
Accept: text/* |
Markdown |
Accept: text/html or Accept: */* |
HTML |
No Accept header |
HTML |
Priority when Cloudflare generates an error: Custom Error Rules → Error Pages → default structured responses in the negotiated format.
How to enable Markdown for Agents on your zone
Section titled “How to enable Markdown for Agents on your zone”Markdown for Agents is available on Pro, Business, and Enterprise plans (and SSL for SaaS) at no extra charge (Markdown for Agents).
- Open the Cloudflare dashboard, select the account and zone.
- Go to AI Crawl Control and turn on Markdown for Agents (content encoding support and improvements).
- Optionally scope the feature with a Configuration Rule: set Markdown for Agents to On for a host or path expression. The API property is
content_converter: true(Configuration Rules settings). - For API-only enablement on the whole zone:
PATCH /client/v4/zones/{zone_tag}/settings/content_converterwith body{"value": "on"}(Markdown for Agents).
For Cloudflare for SaaS, you can enable the feature for all custom hostnames via Quick Actions, or opt in per hostname with custom_metadata.content_converter and a matching configuration rule (Markdown for Agents).
Conversion limits, headers, and Content Signals
Section titled “Conversion limits, headers, and Content Signals”Size and origin behavior
Section titled “Size and origin behavior”Edge conversion now uses an in-process streaming engine (up to 6 MiB decompressed HTML, measured after decompression, not compressed size) (more efficient Markdown for Agents conversion). Earlier limits were 2 MiB; origins no longer need Content-Length, and content-encoded origin responses are supported (improvements post).
Headers preserved vs replaced
Section titled “Headers preserved vs replaced”Markdown for Agents keeps security, cache, and CORS-related headers from the origin (for example Strict-Transport-Security, Content-Security-Policy, Cache-Control, Set-Cookie). It sets Content-Type to Markdown, adds Vary: Accept, removes Content-Length for streamed bodies, and drops headers tied to the original HTML body (ETag, Last-Modified, Content-Encoding, and others) so conditional requests are not applied to converted output (Markdown for Agents).
content-signal policy
Section titled “content-signal policy”If the origin sends a content-signal header, that value is preserved. If it does not, Cloudflare adds:
Content-Signal: ai-train=yes, search=yes, ai-input=yes
(Origin Content Signals). Set your own policy at the origin when you need stricter signals.
Token savings (why Markdown matters)
Section titled “Token savings (why Markdown matters)”On Cloudflare’s docs, one measured page dropped from roughly 15,229 HTML tokens to 2,110 Markdown tokens (~7×) (AI consumability). For 1xxx error pages, Markdown cut payload and token footprint by over 98% versus HTML in 1,015 comparisons (Markdown responses for Cloudflare 1xxx errors).
Workers AI toMarkdown: convert files inside your Worker
Section titled “Workers AI toMarkdown: convert files inside your Worker”When the source is not an HTML page on your zone—or you need PDFs, spreadsheets, or images—use Workers AI Markdown Conversion via env.AI.toMarkdown() or the REST API.
Document conversion plays an important role when designing and developing AI applications and agents. Workers AI now provides the toMarkdown utility method that developers can use … for quick, easy, and convenient conversion and summary of documents in multiple formats to Markdown language.
— Cloudflare, Markdown conversion in Workers AI
Add an AI binding in Wrangler ("ai": { "binding": "AI" }), then pass one or more { name, blob } documents (Workers Binding). AI Search calls toMarkdown automatically when ingesting rich file types.
Supported formats and discovery
Section titled “Supported formats and discovery”Supported extensions include PDF, HTML, images (JPEG, PNG, WebP, SVG, GIF, BMP), Office and ODF formats, CSV, XML, and Apple Numbers (Supported Formats). List formats at runtime:
curl https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/tomarkdown/supported \ -H 'Authorization: Bearer {API_TOKEN}'Or await env.AI.toMarkdown().supported() (new supported-formats endpoint).
GIF and BMP images use object detection plus a vision model; animated GIFs use only the first frame (GIF and BMP support). Image conversions may incur Workers AI model charges beyond free tiers (Markdown Conversion pricing).
conversionOptions: HTML, PDF, images, plain text
Section titled “conversionOptions: HTML, PDF, images, plain text”Optional conversionOptions control behavior:
| Option area | Purpose |
|---|---|
output.format |
markdown (default) or text (Markdown syntax stripped) |
html.cssSelector |
Extract a subtree (for example article.content) |
html hostname |
Resolve relative links |
image.descriptionLanguage |
Language for generated image descriptions |
pdf.metadata |
Set false to omit PDF metadata block |
Plain text output sets each result’s format field to text (plain text output).
Browser Run and other conversion paths
Section titled “Browser Run and other conversion paths”If the page must be rendered in a real browser before conversion, the Browser Run /markdown endpoint is the documented alternative alongside toMarkdown() and Markdown for Agents (Markdown Conversion).
Structured Markdown for Cloudflare errors
Section titled “Structured Markdown for Cloudflare errors”When clients send Accept: text/markdown and no custom error rule or error page overrides the response, Cloudflare-generated 1xxx errors return Markdown with YAML frontmatter and sections What Happened and What You Should Do (Markdown responses for 1xxx errors).
Frontmatter fields include error_code, error_name, error_category, ray_id, timestamp, zone, retryable, retry_after, and owner_action_required. The field once named http_status in Markdown frontmatter was renamed to status—update parsers accordingly (JSON responses and RFC 9457).
Example for operational status pages:
curl -H "Accept: text/markdown" https://www.cloudflarestatus.com/locationsCommon mistakes when serving Markdown to agents
Section titled “Common mistakes when serving Markdown to agents”- Expecting Markdown without enabling the zone feature — negotiation only converts on proxied zones with Markdown for Agents (or Configuration Rule
content_converter) turned on (Markdown for Agents). - Sending
Accept: */*or omittingAccept— you get HTML, not Markdown (error responses). - Relying on
x-markdown-tokensafter edge conversion — newer edge streaming no longer emits those headers; plan token budgets locally (in-process conversion). - Assuming custom HTML error pages are negotiated — uploaded Error Pages ignore
Acceptunless you add matching Custom Error Rules (error responses). - Parsing
http_statusin error frontmatter — usestatusinstead (RFC 9457 changelog). - Hiding the main answer in tabs only — primary instructions should live in the main document flow; agents may not execute tab UI (AI consumability).
How to check this on your site
Section titled “How to check this on your site”- Confirm Markdown for Agents (or a Configuration Rule with
content_converter: true) is enabled for the URL’s zone in AI Crawl Control or Configuration Rules. - Request a known HTML page with
curl -H "Accept: text/markdown" https://your-site.example/path/and verifyContent-Type: text/markdownand readable Markdown body (Markdown for Agents). - Compare response size or token estimates against the same URL without the Markdown
Acceptheader to confirm savings on large pages (AI consumability). - For file pipelines, call
/ai/tomarkdown/supportedwith your API token and run a test conversion on a representative PDF or image (REST API). - You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page is wrong or unclear, email yimasynthetic@gmail.com with the page URL and the exact statement you are asking about, and we will correct or clarify it.