{
  "name": "html-clean-text",
  "summary": "Fetches a web page and returns the article as clean text and markdown, with its declared metadata.",
  "rationale": "It needs the network and a real DOM: boilerplate removal, legacy charset decoding and HTML-to-markdown are three heavy libraries an agent does not carry, and feeding raw HTML to a model instead costs far more in tokens than this call costs.",
  "family": "fetch",
  "price_usd": "0.002",
  "free": false,
  "timeout_ms": 12000,
  "max_timeout_seconds": 33,
  "input_schema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "url": {
        "description": "URL of an HTML, XHTML or plain-text page to fetch, up to 2048 characters; redirects are followed, the body is capped at 1 MB, and exactly one of url or html is required.",
        "type": "string",
        "maxLength": 2048,
        "format": "uri"
      },
      "html": {
        "description": "Inline HTML source to clean instead of fetching, up to 262,144 characters; binary content such as PDF or JSON is refused.",
        "type": "string",
        "minLength": 1,
        "maxLength": 262144
      },
      "base_url": {
        "description": "Base URL for resolving relative links in the html input; not allowed together with url, where the final fetched URL is the base.",
        "type": "string",
        "maxLength": 2048,
        "format": "uri"
      },
      "include_links": {
        "default": false,
        "description": "Also return the links inside the extracted content, each with its text, rel and same-host flag, resolved against the fetched URL or base_url when there is one, else kept as authored.",
        "type": "boolean"
      },
      "readability": {
        "default": true,
        "description": "Run Readability to keep only the main article; false, or an article Readability cannot find, converts the whole body, navigation and footer included.",
        "type": "boolean"
      },
      "max_chars": {
        "default": 50000,
        "description": "Maximum length of text and markdown, 200 to 200,000 Unicode code points (default 50,000); a longer result is cut and flagged as truncated.",
        "type": "integer",
        "minimum": 200,
        "maximum": 200000
      }
    },
    "additionalProperties": false
  },
  "input_example": {
    "url": "https://grist.tools/samples/web/render-article.html",
    "include_links": true,
    "readability": true,
    "max_chars": 2000
  },
  "output_example": {
    "requested_url": "https://grist.tools/samples/web/render-article.html",
    "source_url": "https://grist.tools/samples/web/render-article.html",
    "final_url": "https://grist.tools/samples/web/render-article.html",
    "content_type": "text/html",
    "charset": "utf-8",
    "http_status": 200,
    "title": "Measuring Rainfall with a Simple Gauge",
    "byline": "Sample Author",
    "excerpt": "A short guide to reading a cylinder rain gauge at the same hour every day.",
    "site_name": "Grist Samples",
    "lang": "en",
    "lang_source": "html_lang",
    "text": "A cylinder rain gauge is a clear tube with a scale printed on the side. Rain falls through a funnel at the top and collects in the tube, where the water level shows how much fell since the last reading.\nThe most useful habit is consistency. Read the gauge at the same hour every day, ideally in the morning, so that each number covers one full day.\nPlacing the gauge\nPut the gauge in an open spot, away from walls, trees and roofs. A good rule is to keep it at least twice as far from any obstacle as the obstacle is tall.\nMount it level, so the scale reads true.\nKeep the funnel clear of leaves and insects.\nEmpty the tube right after each reading.\nReading the scale\nBend down until your eye is level with the water. The surface curves slightly where it meets the tube; read the number at the bottom of that curve.\nWrite the reading in a notebook with the date and time. A printable schedule helps when several people share the job.",
    "markdown": "A cylinder rain gauge is a clear tube with a scale printed on the side. Rain falls through a funnel at the top and collects in the tube, where the water level shows how much fell since the last reading.\n\nThe most useful habit is consistency. Read the gauge at the same hour every day, ideally in the morning, so that each number covers one full day.\n\n## Placing the gauge\n\nPut the gauge in an open spot, away from walls, trees and roofs. A good rule is to keep it at least twice as far from any obstacle as the obstacle is tall.\n\n-   Mount it level, so the scale reads true.\n-   Keep the funnel clear of leaves and insects.\n-   Empty the tube right after each reading.\n\n## Reading the scale\n\nBend down until your eye is level with the water. The surface curves slightly where it meets the tube; read the number at the bottom of that curve.\n\nWrite the reading in a notebook with the date and time. A [printable schedule](https://grist.tools/samples/web/render-print.html) helps when several people share the job.",
    "word_count": 178,
    "char_count": 933,
    "truncated": false,
    "readability_applied": true,
    "links": [
      {
        "href": "https://grist.tools/samples/web/render-print.html",
        "text": "printable schedule",
        "rel": null,
        "is_internal": true
      }
    ],
    "link_count": 1,
    "fetched_at": "2026-09-01T12:00:00.000Z"
  },
  "errors": [
    "invalid_input",
    "blocked_target",
    "unreachable_target",
    "upstream_status",
    "upstream_timeout",
    "unsupported_content_type",
    "too_large",
    "unprocessable",
    "internal"
  ]
}