For the complete documentation index, see llms.txt. This page is also available as Markdown.

Generate Markdown

Type: generate_markdown

The Markdown output format exports page data (articles, tables, etc.) in a human- and LLM-readable format, removing unnecessary styling and other "junk" that is only relevant to the site's proper functioning.

Gaffa exports GitHub-flavoured markdown with comments removed and unknown tags ignored.

Tips for using generate_markdown
  • Use this as your default when sending page content to an LLM. It keeps headings, lists, tables and links, and drops the rest.

  • Add a selector to focus on a particular area of the page and cut out the noise. Pointing at article or main skips navigation, sidebars and footers.

  • Use output_type: "inline" to get the Markdown straight back in the response. Use file for long pages.

  • Use generate_simplified_dom instead if you need selectors, because Markdown drops classes and attributes.

Parameters

Name
Type
Required
Description

selector

string

The selector that defines an element you want to generate markdown from. This is useful if you are only interested in the contents of a certain element.

output_type

string

Should the action output be saved to a file where a URL will be returned or should the output be included directly in the request. Default: file Accepted: ["file", "inline"]

See universal parameters.

Usage

The following converts the current page to Markdown:

"actions": [
  {
    "type": "generate_markdown"
  }
]

The following converts only a specific element to Markdown and returns it inline:

Example Output

FAQs

When do I use generate_markdown?

Use it when you want the readable content of a page, article, listing, or documentation page, especially for sending to an LLM. It's the cleanest and smallest output Gaffa produces.

What does generate_markdown output?

It outputs GitHub-flavoured Markdown of the page, with comments removed and unknown tags ignored. Headings, lists, links and tables are kept. Styling and scripts are stripped out.

How do I convert only part of a page to Markdown?

Set the selector parameter to the element you want, like "article" or "main". Gaffa converts only that element's contents, so you skip navigation, sidebars and footers.

Should I use file or inline output?

Use inline to get the Markdown directly in the response, which suits agents and shorter pages. Use file, the default, when the page is long.

When should I use capture_dom instead of generate_markdown?

Use capture_dom when you need the actual markup attributes, scripts, and full link URLs. Use generate_markdown when you only need the content, which is most of the time.

When should I use parse_json instead of generate_markdown?

Use parse_json when you need specific fields in a fixed structure. Use generate_markdown when you want the whole page as text and will handle the rest yourself.

Does generate_markdown keep tables?

Yes, as Markdown tables. If you plan to process the table in code, use parse_table instead; it returns proper JSON rows rather than text.

Should I use file or inline output for generate_markdown?

Use inline to get the Markdown directly in the action's output field, which suits agents and shorter pages. Use file (the default) when the page is long — that returns a storage URL instead.

Last updated