Convert a list of URLs to Markdown files in bulk
Put one URL per line in a text file, send them to a reader API in batches, and write each result to its own .md file. Our Read Many Pages API takes 10 URLs per call for $0.05, so 1,000 URLs are 100 calls or $5, with JavaScript pages, PDFs and Office files handled. The script below does the whole job and logs any page that couldn't be read.
Try it free Read Many Pages API — 10 pages or PDFs as Markdown, $0.05 · $0.05 / call
The script
Node 18 or later. payFetch is fetch wrapped by any x402 v2 client; it pays each call in USDC on Base.
import { readFile, writeFile, mkdir } from "node:fs/promises";
const API = "https://iamai.markets/api/x402/services/29xjjqqL1UPd";
const urls = (await readFile("urls.txt", "utf8")).split("\n").map((s) => s.trim()).filter(Boolean);
await mkdir("md", { recursive: true });
const slug = (u) => u.replace(/^https?:\/\//, "").replace(/[^a-z0-9]+/gi, "-").slice(0, 80);
const failed = [];
for (let i = 0; i < urls.length; i += 10) {
const batch = urls.slice(i, i + 10);
const r = await payFetch(API, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ urls: batch, max_chars_per_page: 50000 }),
});
if (!r.ok) { failed.push(...batch); continue; } // whole batch failed: not charged
const { result } = await r.json();
for (const p of result.results) {
if (!p.ok) { failed.push(`${p.url} ${p.error}`); continue; }
const front = `---\nsource: ${p.url}\ntitle: ${JSON.stringify(p.title ?? "")}\nwords: ${p.word_count}\n---\n\n`;
await writeFile(`md/${slug(p.url)}.md`, front + p.markdown);
}
console.log(`${Math.min(i + 10, urls.length)} / ${urls.length}`);
}
await writeFile("failed.txt", failed.join("\n"));
What it costs
A batch is charged only if at least one page in it is read. Batches of fewer than 10 cost the same $0.05, so fill them where you can.
| URLs | Calls | Batch reader ($0.05 per 10) | Single reader ($0.02 each) |
|---|---|---|---|
| 10 | 1 | $0.05 | $0.20 |
| 100 | 10 | $0.50 | $2.00 |
| 1,000 | 100 | $5.00 | $20.00 |
| 10,000 | 1,000 | $50.00 | $200.00 |
Before you run it
If a whole batch fails, the API answers with an error and nothing is charged, so the script puts all 10 URLs in failed.txt for another try.
- Clean the list: remove duplicates, tracking parameters such as utm_source, and links to images or videos.
- Try three or four of the URLs free on the listing page to see what the Markdown looks like for your sites.
- Run the script on the first 20 URLs, read a few files, then run the rest.
- Re-run failed.txt later. Pages that timed out or were briefly down often work on a second try.
Settings worth knowing
- max_chars_per_page: 1,000 to 50,000, default 20,000. Raise it for long docs, lower it to keep LLM prompts small.
- Each result has title, language and word_count, handy for skipping near-empty pages.
- Pages that need JavaScript are opened in a real browser automatically; you don't set anything.
- The same URL twice in a batch is read once.
Other ways to do it
| Tool | Fits when |
|---|---|
| pandoc | You already have the HTML files saved locally |
| Firecrawl batch scrape | You use Firecrawl already and have credits |
| Jina Reader in a loop | Pages are short and you're within its free limits |
| Crawl4AI | You want to run everything yourself in Python |
The product
Questions
Does it download images?
No. You get the text of each page as Markdown; image files aren't saved.
Can it read pages behind a login?
No. It reads public URLs only.
How do I test before paying?
Use the listing page: 5 free tries a day with your own URLs.
Can it handle PDFs in the list?
Yes. PDF links, and Word, Excel and PowerPoint files, are read like web pages and returned as Markdown.
Related
Updated 2026-12-02
