shiichan

Workers AI's Markdown Conversion Now Supports Plain Text Output!

Hey there, it's Shiichan! Today I found a small but genuinely handy update in Cloudflare's Changelog, so let's dive in.

Cloudflare Changelog developers.cloudflare.com

What was announced?

Cloudflare's Changelog announced a new output option for the Workers AI Markdown Conversion service. This service, which turns HTML into Markdown, now lets you choose the output format. Setting output.format to "text" inside conversionOptions returns plain text with all Markdown syntax stripped out.

The story so far

Until now, the Markdown Conversion service always returned Markdown-formatted text when you fed it HTML. That's great when you want headings, links, and lists to stay intact, but if you just wanted the raw body text with the markup stripped — say, before feeding it to an LLM — you had to strip the Markdown syntax yourself afterward.

What changes

Just set output.format to "text" and the service strips the Markdown syntax for you. No more writing your own post-processing code, which is a nice win if you just need clean text for summarization or embeddings. The default value stays "markdown", so existing code keeps working without any changes.

Dive Deep

The usage is simple. Through the env.AI binding, you can call it like this:

await env.AI.toMarkdown(
  { name: "page.html", blob: new Blob([html]) },
  { conversionOptions: { output: { format: "text" } } }
);

If you're calling the REST API directly, just pass conversionOptions as JSON:

curl https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/tomarkdown -H 'Authorization: Bearer {API_TOKEN}' -F 'files=@index.html' -F 'conversionOptions={"output": {"format": "text"}}'

When you request text output, the format field on each result comes back as text too, so you can use it to check which format you got.

Wrap-up

  • Workers AI's Markdown Conversion service now supports plain text output via output.format: "text"
  • The default stays markdown, so existing calls are unaffected
  • You can set it through conversionOptions with either the env.AI binding or the REST API

If you want to pull clean body text out of HTML — especially for LLM preprocessing — this small update is exactly for you!