Convert a website to Markdown
Convert a web page to Markdown, export it safely, and test preserved content and parsed tables, code, headings and links with reproducible examples.
By Codex. Checked 2026-11-04.
Convert one page first
To turn a web page into Markdown, send its URL to Scraipe's POST /v1/read endpoint with format: "markdown", then save the response's content string. Check the returned format and truncation flag before naming the file .md. Saving the entire JSON response produces a JSON document containing Markdown, not a Markdown document.
One Read request converts one fetched page. Converting a website with many pages requires a separate decision about which URLs to include; the endpoint does not automatically walk every link. Start with one permitted public page, inspect the output, and expand coverage only after the result suits your application.
This guide includes a local conversion fixture and a tested export command. The fixture was converted by Scraipe's repository reader on 23 October 2026; it is not a captured hosted API request or evidence of a customer result.
Send an explicit Markdown request
Create a Scraipe key with the read scope in the console. Keep it in your local secret-management environment as SCRAIPE_API_KEY. The example uses Node 22 for the export step and a recent curl supporting --fail-with-body. Choose a new working directory so you can retain the response for inspection.
bash
curl --fail-with-body --silent --show-error --max-time 25 \
'https://scraipe-fc66a552921e.herokuapp.com/v1/read' \
-H "Authorization: Bearer ${SCRAIPE_API_KEY}" \
-H 'Content-Type: application/json' \
--data '{
"url": "https://example.com/",
"format": "markdown",
"mainOnly": true,
"includeLinks": true,
"maxChars": 20000,
"egress": "direct"
}' \
--output read.jsonRun the export only after curl exits successfully. An HTTP error can leave an error body in read.json, and a transport failure can leave an incomplete capture. The example does not retry automatically. A client timeout does not prove the server stopped processing the request.
example.com is an illustrative public input, not an assertion that our publication run fetched it through the hosted API. Replace it with the page you have permission to process. The API reference defines authentication, refusal reasons and request limits.
| Request field | Why it is explicit here |
|---|---|
format: "markdown" | Requests Markdown; inspect the response because conversion can fall back to text. |
mainOnly: true | Selects likely main content and removes boilerplate; selection is heuristic. |
includeLinks: true | Preserves link destinations in the conversion and a separate links collection. |
maxChars: 20000 | Limits returned content size; it can produce a partial document. |
egress: "direct" | Uses the direct network path and prevents residential fallback for this request. |
Read's direct-network conversion uses no language model and has no conversion credit charge under the current contract. That is not an unlimited-throughput promise: concurrency, queue, access and size limits still apply. Residential reads have separate network charges; this procedure neither enables nor verifies residential service. Inspect meta.credits.total and the request receipt guide when checking a hosted run's actual cost.
Export the content without overwriting a file
Download these four files into one directory:
No npm installation or API key is needed for the local example. Using Node 22 or later, run:
bash
node --test export-read-markdown.test.mjs
node export-read-markdown.mjs website-markdown-read.fixture.json fixture.mdExpect fourteen passing tests and a small JSON status with written: true, format: "markdown" and the UTF-8 byte count. Open fixture.md; the file itself contains the Markdown, without JSON quotation marks or escaped newline characters. To export your own successful response instead:
bash
node export-read-markdown.mjs read.json page.mdThe exporter requires ok: true, format: "markdown", nonempty content and stats.truncated: false. It reuses the Read acceptance checks, then writes the exact content string. It does not add a title, strip formatting, infer missing text or manufacture a receipt. Keep the original JSON alongside the Markdown when you need its source URL, metadata, links and request receipt.
The destination must be a new .md path. Existing files and symbolic links are refused. The script prepares the content in the destination directory and uses a hard link to install it without replacing an existing target; your filesystem must support that operation. The input is bounded to 1 MiB of valid UTF-8 JSON. A larger capture is refused by this example, even if the API accepted the original request.
| Exit code | Meaning |
|---|---|
0 | A new Markdown file was written. |
1 | The captured response failed the content acceptance checks. |
2 | Usage, input parsing, output-path or filesystem failure. |
Diagnostics omit captured content and input paths. The script reads local files only; it does not authenticate, fetch a page or validate the truth of the page's claims. Its acceptance checks also do not certify formatting fidelity, correct main-content selection or source-origin policy.
Compare the conversion with its source
The invented HTML fixture contains prose, headings, a list, a relative link, a code block, a table and labelled boilerplate. Our local reader run produced Markdown with this structure:
markdown
# Deployment notes
## Before release
- Check the output format.
- Inspect the saved Markdown.
Read the [reference guide](https://example.com/reference) before proceeding.This is a shortened excerpt; the downloadable fixture contains the full result. The code block retained its JavaScript fence and contents. The navigation, sidebar, footer and script sentinels were absent. Those are measurements of this deliberately small fixture, not a guarantee for every website.
The table exposed a useful limit. The current reader emitted these rows:
text
| Stage | Result |
| Local fixture | Review manually |They preserve the cell text but lack the delimiter row required by the GitHub-flavoured Markdown table specification. Do not assume that a .md filename guarantees a correctly rendered table. For critical tabular data, use structured extraction and validate the cells, or explicitly transform and test the table for your chosen renderer.
Scraipe's reader uses Turndown with its own content-selection and conversion rules. Turndown's primary documentation describes configurable heading and code-block styles and optional GFM plugins. A capability available through a library plugin is not proof that a deployed service enabled it.
Make conversion checks repeatable
A .md file can export successfully while still missing the section your application needs. Before accepting repeated conversions, write down a few explicit expectations about the intended source and its output. The conversion-check pack below turns those expectations into named pass/fail checks, without fetching a page or asking a model to judge its own output.
Download these three new files beside the exporter, acceptance helper and Read-result fixture listed above:
The checker needs six files in total: these three, export-read-markdown.mjs, audit-read-result.mjs and website-markdown-read.fixture.json. It uses only Node 22's built-in modules. No installation, network request or key is required. From that directory, run:
bash
node --test check-markdown-contract.test.mjs
node check-markdown-contract.mjs website-markdown-read.fixture.json markdown-conversion.contract.jsonExpect thirteen passing tests and a report with accepted: true, nine passing named checks and a content SHA-256. The fixture digest is:
text
283ac0ec7a9b5eddcd464f94f3da9c447c7f6927dbadec724dd594eb2d4ac823It identifies these exact stored bytes; it is not evidence of a hosted request, a retrieval time or an authentic publisher.
The contract requires the expected title and section, the absolute reference link, a complete fixture code block and the table's data-row text. Four exclusion rules reject the fixture's known navigation, sidebar, footer and script markers. The checker also requires the exact returned source URL, accepted Markdown, nonempty well-formed Unicode, explicit untruncated status and no contradictory fallback metadata.
These are literal, case-sensitive checks. They deliberately do not parse the whole Markdown document or certify its rendering. In particular, the table-cell rule passes the measured fixture even though it lacks a GFM delimiter row. Passing a content-preservation rule does not repair that known formatting limitation.
Prove a broken conversion is rejected
A useful acceptance pack must reject a deliberately damaged result. Create a new test capture with the reference destination removed:
bash
node --input-type=module -e '
import fs from "node:fs";
const input = JSON.parse(fs.readFileSync("website-markdown-read.fixture.json", "utf8"));
input.content = input.content.replace("[reference guide](https://example.com/reference)", "reference guide");
fs.writeFileSync("missing-link.json", JSON.stringify(input, null, 2), { flag: "wx" });
'
node check-markdown-contract.mjs missing-link.json markdown-conversion.contract.jsonThe creation command refuses an existing missing-link.json. The checker reports accepted: false, the reference-link check fails and the process exits with code 1. The synthetic response still says ok: true and truncated: false: those transport/completeness fields cannot detect this deliberately removed destination. The original fixture remains unchanged.
| Checker exit | Meaning |
|---|---|
0 | The response and all declared literal rules pass. |
1 | The response or at least one rule fails; inspect the named checks and issue codes. |
2 | Invalid input, contract, usage or local-file error; no acceptance result was established. |
For your own source, copy and review the contract before applying it to captured output. Set expectedUrl to the exact returned page address you intend to accept, including any meaningful query. An intentional redirect or changed query needs an explicit policy update; a same-origin login page should not inherit approval just because its hostname matches. Keep the original requested and returned addresses when investigating a mismatch.
Choose stable, task-specific snippets from an independently inspected source. Do not generate the expected snippets from the candidate being checked: an already damaged candidate could approve itself. Use short nonsecret rule IDs because the report includes those labels. Rule bodies are literal strings, not regular expressions; no arbitrary pattern or code execution is supported.
The JSON capture and contract each have a 1 MiB file limit. A contract permits 1–64 rules, each with up to 4,096 UTF-16 code units. Reports include rule IDs, booleans, issue codes and a digest, but omit page content, source URLs and receipts. Retain the underlying captures securely for diagnosis.
For a repeat run, compare both the report and digest. Additional legitimate prose changes the digest while the declared rules may still pass. A digest change means “different bytes,” not automatically “bad conversion.” Conversely, a passing rule set covers only what you declared; unrelated missing sections, misleading text or unknown navigation noise can escape it. Add a reviewed rule or inspect the page when those details matter. Do not loosen a failing rule merely to make a deployment pass.
Check the parsed document as well as the text
A literal check answers whether selected text survived. A parser check answers whether the consumer will recognize that text as the intended Markdown structure. The existing fixture passes all nine literal rules, but its two pipe-separated rows become paragraph text in the parser used below. A table-shaped string is not sufficient evidence of a table.
On 4 November 2026, the current repository reader reproduced the original fixture's content bytes, link output, code fence and option behavior. We then parsed that exact content with markdown-it 15.0.3. It produced three headings, one code block and one link, but zero tables. This is local reproduction using invented source HTML; it is not a new hosted Read request or customer incident.
The markdown-it documentation describes its parsing API and configuration. This example uses its default preset with html: false, linkify: false and typographer: false, and no additional plugins. Tables are enabled by this preset. These choices matter: changing parser versions, options or plugins can change the document a consumer sees. The test covers this configuration, not every Markdown editor or GitHub's complete rendering pipeline.
Download all eight files into a new directory:
- Parser-shape checker
- Seventeen tests
- Reviewed expected structure
- Original reader output
- Separate fixture with a reviewed table correction
- Pinned package manifest
- Portable dependency lockfile
- Payload checksums
Use Node 22; the fresh-install checks used Node 22.23.2. The package install downloads dependencies from the npm registry. The subsequent tests and checker run locally, make no requests to Scraipe and spend no API credits. Run:
bash
shasum -a 256 -c SHA256SUMS
npm ci --ignore-scripts --no-audit --no-fund
npm test
node check-rendered-shape.mjs reader-output.md expected-shape.jsonSeventeen tests should pass. The final command intentionally exits 1, with accepted: false; only the tables check fails, with expectedCount: 1 and actualCount: 0. An expected nonzero exit is the successful negative control here, not an installation problem.
Now check the separately corrected fixture:
bash
node check-rendered-shape.mjs reviewed-table.md expected-shape.jsonIt exits 0 with all four category checks passing. This file adds only one delimiter row between the known header and data row:
text
| Stage | Result |
| --- | --- |
| Local fixture | Review manually |The original reader output and captured JSON remain unchanged. This is a manually reviewed correction to one invented fixture, not an automatic repair rule or a change to the service's converter. Do not insert delimiter rows into arbitrary pipe-containing prose or code. For an important real table, inspect the source's headers and cells, preserve the original capture, and test any transformation separately. Complex spanning cells and nested tables may require structured extraction instead.
Define what a rendering check must preserve
The expected-structure file records three heading levels/texts, the complete two-row table grid, the JavaScript code block's information string and exact text, and the reference link's text/destination. The checker compares parsed structures, rather than searching for Markdown punctuation. It detects a changed cell even when the table count is still one, and a changed destination even when the visible link label stays the same. A table inside a code fence does not count as a table.
| Condition in the tests | Result |
|---|---|
| Original reader output without the delimiter row | Rejected: no parsed table |
| Reviewed fixture with that row added | Accepted by all four structure checks |
| Reference-style link with the same label and destination | Accepted: different Markdown syntax, same checked link |
| Wrong table cell, heading level, code value or link destination | Rejected by the relevant category |
| An unclosed code fence consumes later content | Rejected: the parsed structure changes |
| An unlisted prose paragraph is removed | Can still pass: prose completeness is outside this policy |
Use independently inspected source expectations when adapting expected-shape.json. Do not generate the expected structure from the candidate you are trying to validate; a broken conversion could then approve itself. This small policy compares exact counts and order within each category. It does not check the relative placement of headings, tables, code and links across categories, ordinary prose, images, list nesting, styling or factual accuracy. Inline formatting is reduced to text for heading labels and cells. Keep the earlier literal checks where they cover additional reader requirements, and inspect the final renderer when presentation matters.
The parser recognizes indented and fenced code blocks; the policy requires the information string and content supplied by the parser, including its code-text newline. Raw HTML is disabled, so an HTML table does not satisfy the Markdown-table requirement. This checker neither renders a public page nor certifies an HTML sanitization policy. Rendering untrusted content remains the consuming application's responsibility.
The CLI reads regular UTF-8 files with a bounded 1 MiB limit per input. Markdown must be nonempty and well-formed Unicode. Version 1 permits up to 100 entries per category, 100 rows per table, 30 cells per row and 65,536 UTF-16 code units per expected text field. Reports contain category IDs, counts, booleans and a content digest; they omit document text and link destinations. Exit 2 means invalid usage, input, policy or local-file failure, rather than a content rejection.
An unchanged digest plus a different result after a dependency update points toward parser/configuration changes. A different digest with passing structure checks means only that the checked categories still match. Neither observation establishes that every relevant word survived. Keep the source capture, policy and parser lockfile together when reviewing a conversion change.
Adjust selection without promising a page clone
If expected prose is missing, compare the returned content with the original page before changing limits. mainOnly: false broadens the conversion to the cleaned page, but it is not an archive of the original HTML. In the local fixture, navigation remained removed even with that option. Scripts, forms and interactive behavior do not become working Markdown features.
With includeLinks: false, the local reader retained the reference link's visible words but removed its Markdown destination. Use that deliberately; losing destinations can make a document less useful outside its original page. Images, complex layouts, code languages and nested tables deserve separate inspection when they matter to the consumer.
A page that needs browser rendering or sign-in may not provide the same content as a simple public page. Inspect the returned refusal or available rendering options. A login page or consent notice that converts successfully still may not be the content you intended to read.
Stop on partial or mismatched output
A successful HTTP status does not establish a complete Markdown document. Handle these cases before ingestion:
| Result | Next action |
|---|---|
format: "text" with stats.fallback | Retain it as text if that satisfies the task; do not relabel it Markdown. |
stats.truncated: true | Treat the document as partial. Reconsider the size limit or source scope; do not silently append unrelated reads. |
| Blank output or missing expected sections | Inspect the source and selection; reject the output when the needed content is absent. |
401 or insufficient_scope | Correct the key or permission before retrying. |
429 concurrency_limit or 503 reader_busy | Respect available retry guidance and reduce concurrency. |
Access refusal or too_complex | Inspect the reason; repeating the same request is not a conversion strategy. |
The reader can cut content inside a code block or table when a character limit applies. Our forty-character fixture run reported truncation; the exporter refuses that state. Conversely, truncated: false only says this size limit did not cut the returned content. It does not prove that every relevant section of the website was selected.
Treat downloaded page content as untrusted data. Keep instructions from the page separate from instructions to an agent, and use your renderer's appropriate safety settings when displaying Markdown.
Expand to a website with an explicit URL list
After one page passes inspection, choose the intended site sections and bounds. The API's Map operation can help discover URLs; Crawl can process a bounded set. Their results and permissions differ from a single Read response, so do not feed an entire crawl-job JSON object into this exporter. Review the API contract, define exclusions and check coverage before treating the output as a website copy.
For a first trial, open the playground, compare one permitted source page with its reader output, and save only the representation your application actually needs.