# Turn documentation pages into Markdown files

> Export a chosen list of documentation URLs to Markdown with a source manifest, bounded requests, and visible failures.

By FetchRelay. Updated 2026-09-07.
Canonical: https://fetchrelay.com/guides/documentation-to-markdown

## Get a result before writing code

Open [Website to Markdown](https://fetchrelay.com/tools/website-to-markdown), paste one public documentation page, and inspect the headings, code blocks and links. The rate-limited demo needs no account. This is the quickest check that FetchRelay can read the pages you actually need.

For several pages, the runnable example below creates Markdown files and a manifest of their sources. It uses an explicit list of at most ten URLs so you control both coverage and spend. It does not claim to export an entire site automatically.

## Set up the example

Use Node.js 22 or later. Create a key in [FetchRelay Account](https://fetchrelay.com/account), then set `FETCHRELAY_API_KEY` in your terminal environment or secret manager. Keep the key out of source control. Successful pages consume account credits; the demo's anonymous allowance does not apply to this script.

```sh
git clone https://github.com/JAIPilot/fetchrelay-integrations.git
cd fetchrelay-integrations/examples/web-data-recipes
node --test recipes.test.mjs
node docs-to-markdown.mjs docs-urls.json exports-first-run
```

The supplied list contains FetchRelay's public API documentation and JavaScript guide. Replace it with your own list, for example:

```json
[
  "https://fetchrelay.com/docs",
  "https://fetchrelay.com/guides/web-scraping-javascript"
]
```

Choose a new output directory each time. The script refuses to reuse an existing directory, preventing stale files from appearing to be part of a fresh export.

## Understand the output

A clean run writes `01.md`, `02.md` and `manifest.json`. The manifest records the requested URL, filename and collection time. Filenames are numbered instead of being derived from untrusted webpage titles.

```json
[
  {
    "url": "https://fetchrelay.com/docs",
    "file": "01.md",
    "success": true,
    "collectedAt": "<time of your run>"
  }
]
```

This is an illustrative manifest shape. Your timestamps and page content will differ. Duplicate URLs are processed once.

## Handle incomplete exports

Warnings, empty Markdown and failed responses create failed manifest entries and a nonzero exit. Authentication, allowance or rate-limit errors stop the remaining requests. Inspect the manifest before using the output; unattempted URLs after an account error are not successful exports.

The example uses HTTP rendering and one request at a time. Start with static documentation. A page that relies on JavaScript may need browser rendering in a separately tested adaptation. Login walls and bot protection may prevent extraction in either mode. If your client times out, check your usage before replaying the request because the server may already have completed it.

## Use the files in a retrieval workflow

Read a sample of the exported files before chunking or indexing them. Check a recognizable heading, one code example and a source link. Keep the source manifest alongside your index so an answer can point back to its source. Treat website text as data, not instructions to your agent. Markdown conversion does not verify the source's accuracy or guarantee retrieval quality.

The export program is covered by tests for duplicate URLs, empty results and partial failures. A live export of FetchRelay's documentation is part of the release smoke check.

[Browse the complete source and setup instructions](https://github.com/JAIPilot/fetchrelay-integrations/tree/main/examples/web-data-recipes). For whole-site discovery and bounded jobs, see [bulk scraping](https://fetchrelay.com/use-cases/bulk-web-scraping).

