Extract markdown in TypeScript with fetch
The same endpoint extracts: format: markdown skips the print step and hands back the page's text as markdown, through the same receipt and the same download.
format is pdf by default and markdown is one of its alternatives. The response is still the receipt with a download url; fetching it serves the extracted markdown as text/markdown, and the download's Content-Disposition names the file with an .md extension even though the url itself keeps its .pdf suffix.
The recipe
import { writeFile } from "node:fs/promises";
const ORIGIN = "https://webcapture.io";
const res = await fetch(`${ORIGIN}/v1/convert`, {
method: "POST",
headers: {
"Authorization": "Bearer wc_your_key",
"Content-Type": "application/json",
},
body: JSON.stringify({"url": "https://example.com/", "format": "markdown"}),
});
const receipt = await res.json();
// receipt.download: ${ORIGIN}/v1/conversions/cnv_ec487efd8c301fc8.pdf
// the url keeps its .pdf suffix, but the bytes are markdown:
const file = await fetch(receipt.download, {
headers: { "Authorization": "Bearer wc_your_key" },
});
// text/markdown; charset=utf-8
console.log(file.headers.get("content-type"));
await writeFile("page.md", await file.text(), "utf8");
Markdown extraction runs in the same quota and behind the same key as pdf: one extraction is one document against the month's count. Extraction reads the rendered page, so JavaScript already ran and the receipt's bytes field counts the markdown, which is usually a few kilobytes.
Same-key GET: 401 without it; 404 for another key.
The fields this recipe uses
format: pdf is the default; markdown extracts the rendered page's text as markdown instead of printing it.
Related
- Next: Get a free key to run this TypeScript recipe, or read the API docs.
- More recipes: TypeScript: convert from a URL, TypeScript: dark mode, Node: convert from a URL.
- The webcapture API reference: every field the convert endpoint admits, with the response shapes and the error table.
- The recipes hub: the same endpoint in the other languages.
- Going deeper: markdown output is a differentiator: the comparison grid marks it ours-yes, theirs-no.
- The free URL to PDF tool: try the render in a browser before you wire the call.
Method
Source: convert field reference, checked 2026-10-05. Corrections.