Conversion Options

Last updated Oct 15, 2026 By default, the toMarkdown service extracts text content from your files. To further extend the capabilities of the conversion process, you can pass options to the service to control how specific file types are converted.

Options are organized by file type and are all optional.

Available options

Output

{
  output?: {
    format?: 'markdown' | 'text';
  }
}
  • format: controls the format of the converted content. Defaults to markdown. Set to text to receive plain text with Markdown syntax removed.

When format is text, the format field of the ConversionResult is also set to text.

Images

{
  image?: {
    descriptionLanguage?: 'en' | 'it' | 'de' | 'es' | 'fr' | 'pt';
  }
}
  • descriptionLanguage: controls the language of the AI-generated image descriptions.

Caution

This option works on a best-effort basis: it is not guaranteed that the resulting text will be in the desired language.

HTML

{
  html?: {
    hostname?: string;
    cssSelector?: string;
  }
}
  • hostname: absolute base URL used to resolve relative links in the HTML. Include the scheme and, when applicable, the page path — for example, https://example.com/docs/page. A bare hostname such as example.com is not sufficient.
  • cssSelector: string containing a CSS selector pattern to pick specific elements from your HTML. Refer to how HTML is processed for more details.

PDF

{
  pdf?: {
    metadata?: boolean;
  }
}
  • metadata: Previously, all converted PDF files always included metadata information when converted. This option allows you to opt-out of this behavior.

Examples

Binding

To configure custom options, pass a conversionOptions object inside the second argument of the binding call, like this:

await env.AI.toMarkdown(..., {
  conversionOptions: {
    html: { ... },
    pdf: { ... },
    ...
   }
})

REST API

Since the REST API uses file uploads, the request's Content-Type will be multipart/form-data. As such, include a new form field with your stringified object as a value:

curl https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/tomarkdown \
  -X POST \
  -H 'Authorization: Bearer {API_TOKEN}' \
  ...
  -F 'conversionOptions={ "html": { ... }, ... }'

Was this helpful?

YesNo

On this page

Conversion Options - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/#page","headline":"Conversion Options","description":"Configure per-format options for Workers AI Markdown Conversion, including HTML and image settings.","url":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/og.png?v=3a136bcaa6901b43","dateModified":"2026-10-15","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Learn how Workers AI pre-processes and converts HTML, images, and other files to Markdown. title: How it works image: https://developers.cloudflare.com/workers-ai/features/markdown-conversion/how-it-works/og.png?v=54dd4472fb6acd18


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt
Use this file to discover all available pages before exploring further.