Workers AI - Plain text output for Markdown Conversion
Key Points
- plain-text output option
- removes Markdown syntax
- works via env.AI and REST API
Summary
The Workers AI Markdown Conversion service adds a new output option. Set conversionOptions.output.format to text to receive plain text with Markdown syntax removed. The default remains markdown, so existing conversions are unaffected. When you request text output, each result's format field is set to text.
Key Points
- New option:
conversionOptions.output.format = "text"returns plain text with Markdown stripped. - Default behavior unchanged:
markdownremains the default output format. - Supported in both env.AI bindings and the REST API; response
formatwill betextfor these requests.
Examples
- env.AI (JavaScript/TypeScript):
await env.AI.toMarkdown({ name: "page.html", blob: new Blob([html]) }, { conversionOptions: { output: { format: "text" } } }) - REST API (curl):
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"}}'
Migration / Notes
- No changes required for existing integrations unless you want plain-text output.
- Check the response
formatfield to detect plain-text results.