When you scrape a website to markdown for an LLM, converting the page is the easy part. Firecrawl's own docs show a "clean" result that opens with a promo banner. Apify's sample output opens with a "Skip to main content" link.
That leftover text gets chunked, embedded and retrieved like everything else. Then your chatbot quotes a cookie notice back at a customer.
So this guide covers the rest: which tool to use, the exact settings that strip the junk, how to cap a crawl before it eats your credits, and how to chunk the markdown so retrieval finds the right section. If you're new to the bigger picture, start with what RAG is and how retrieval-augmented generation works, then come back.
Everything here is from Firecrawl's, Apify's and LangChain's current docs and pricing pages, as of 22 October 2026. The code samples follow those docs. I haven't run them against your site, so test on five pages before you crawl five thousand. Some links are affiliate links; they don't change your price.

Why do LLMs need markdown instead of raw HTML?
The short answer: markdown keeps the structure an LLM needs and drops the markup it doesn't.
A raw HTML page is mostly scaffolding. Script tags, class names, tracking pixels, nav menus, inline styles. Feed that to a model and you pay tokens for noise, and the noise competes with the facts for the model's attention.
Plain text goes too far the other way. It throws away the headings, lists and tables that tell the model what belongs together.
Markdown sits in the middle. A heading stays a heading (## Pricing), a table stays a table, and a link keeps its URL. That structure matters twice: once when the model reads the page, and again when you split it into chunks, because headings are the natural places to cut.
My take: treat markdown as the format your pipeline stores, not a nice-to-have. Every step after it gets easier.
What does a clean scrape-to-markdown pipeline look like?
It's four steps, and only the first one is "scraping":
- Scrape or crawl: fetch the pages, render JavaScript where needed, convert to markdown.
- Clean: strip what the tool missed, drop error pages, remove duplicates.
- Chunk: split on headings, then cap the size.
- Embed and store: turn each chunk into a vector with its source URL attached. The vectors live in a vector database, which finds the chunks closest to each question.

Firecrawl and Apify both handle the first step well. Neither one does the second step for you completely, which is the part most tutorials skip.
If you only need one page in a chat window, stop at step one. If you're building search or a support bot over a whole docs site, you need all four. If you need typed fields like prices or dates instead, swap the last two steps for a schema, as in my guide to extracting structured data with an LLM.
Firecrawl or Apify: which should you use for markdown?
Both turn web pages into LLM-ready markdown. They're built differently, and that decides it.
Firecrawl is an API. You send a URL, you get markdown back in the response. Billing is in credits: 1 credit per scraped page, per Firecrawl's scrape docs.
Apify's Website Content Crawler is an Actor (Apify's name for a packaged cloud program) that runs on Apify's platform. You give it start URLs and settings, it crawls, and the markdown lands in a dataset you fetch afterwards. Billing is compute time, not pages.
| Question | Firecrawl | Apify Website Content Crawler |
|---|---|---|
| How you call it | REST API or SDK, result in the response | Actor run, results in a dataset |
| Single page | One scrape call | Works, but Apify suggests its RAG Web Browser Actor for single URLs |
| Whole site | Crawl endpoint, default limit 10,000 pages | Crawl is the main job, default max pages effectively unlimited |
| Boilerplate removal | onlyMainContent on by default, plus include and exclude CSS selectors | Removes nav and footer by default, plus a choice of HTML transformers |
| Pricing model | Credits: 1 per page | Compute units: Apify estimates $0.5 to $5 per 1,000 pages with a browser |
| Free tier | 1,000 credits a month with a free key | $5 of usage a month |
| No account needed | Scrape works keyless, rate-limited per IP | No, needs an API token |
Pick Firecrawl if you want markdown inside your own code path: an API route, an agent tool, a script that scrapes on demand.
Pick Apify if you want to point a crawler at a large site, tune it in a UI and schedule it, and you're fine collecting results from a dataset.
My full Firecrawl vs Apify comparison goes deeper on pricing and scale. For the rest of this guide, I'll show both.

How do you scrape one page to markdown with Firecrawl?
Step 1: Make the request
This is the cURL version from Firecrawl's docs, with markdown as the only format. Firecrawl's docs say scrape works without an API key on a keyless tier that's rate-limited per IP. Add the header once you have a key.
onlyMainContent is already true by default, per Firecrawl's advanced scraping guide. I set it anyway so the intent is visible. excludeTags takes CSS selectors, and Firecrawl applies them to the original page HTML. So target the selectors you see in the page source, not in the markdown.
Step 2: Check the page status as well as the API status
Here's the catch. Firecrawl returns HTTP 200 with success true when the API call worked, even if the page behind it answered 404 or 403.
The page's own status is in data.metadata.statusCode. Firecrawl treats 2xx and 304 as a clean load. Anything else means you just scraped an error page, and it still cost a credit. Drop those before they reach your index.
Step 3: Do the same in Python
The Python SDK follows the same shape. This is the scrape call from Firecrawl's docs, with only markdown requested:
The SDK turns the API's camelCase names into snake_case, so sourceURL becomes source_url and onlyMainContent becomes only_main_content.
Want more single-page patterns, like JSON extraction or screenshots? My Firecrawl API examples cover them one by one.
How do you crawl a whole site to markdown without burning credits?
Step 4: Always set a limit
Firecrawl's crawl endpoint follows the sitemap and internal links, and scrapes every page it finds. The default limit is 10,000 pages, at 1 credit each.
Before it starts, Firecrawl checks that your remaining credits cover that limit. If they don't, you get a 402 Payment Required error, per the crawl docs.
On the free plan's 1,000 credits, an uncapped crawl fails before it begins. That's the good outcome. On a paid plan, it might not fail, and a 10,000-page crawl is 10,000 credits. My breakdown of Firecrawl's credit pricing shows what that means on each plan.
The crawl call waits for the job to finish and handles pagination for you. scrape_options applies the same settings to every page.
Step 5: Decide how fresh the pages must be
max_age is the cache window. Firecrawl's default is 172,800,000 milliseconds, which is two days. If a cached copy is younger than that, you get the cached copy.
For docs that change weekly, two days is fine and faster. For pricing pages or anything you'll quote as current, set it to 0 so every page is fetched fresh.
Step 6: Narrow the crawl to the pages that matter
Two crawl options save the most credits. includePaths and excludePaths take regex patterns matched against the URL path, so you can keep /docs/ and skip /blog/tag/. maxDiscoveryDepth caps how many link hops the crawler follows from the start URL.
Not sure what a site contains? Firecrawl's map endpoint lists a site's URLs for 1 credit per call, however many it returns. Map first, pick the sections, then crawl. Firecrawl notes map favours speed and may miss some links, so treat it as a survey, not a guarantee.
Building this into a web app rather than a script? My Firecrawl tutorial with Next.js shows the server-side setup with the key kept out of the browser.
How do you crawl a site to markdown with Apify?
Step 7: Run Website Content Crawler from Python
This follows the Python example on the Actor's API page, trimmed to the settings that matter for markdown:
Step 8: Know which settings do the cleaning
Three settings carry most of the weight, per the Actor's input schema:
- crawlerType: playwright:adaptive switches between a browser and plain HTTP and is the option Apify recommends. cheerio is fastest but doesn't run JavaScript, so it misses content on JavaScript-rendered sites.
- removeElementsCssSelector: elements deleted before text extraction. The default already covers nav, footer, scripts, banners and dialogs. Add your site's cookie bar or sidebar here.
- htmlTransformer: how the remaining HTML is reduced to the readable part. The default is readableText. If content goes missing, Apify's docs suggest trying another transformer, or none.
Set maxCrawlPages every time. Its default is 9,999,999, which Apify itself calls effectively unlimited.
On cost, Apify's README estimates $0.5 to $5 per 1,000 pages with a headless browser, and about $0.2 per 1,000 with the raw HTTP crawler. That's at their baseline of $0.25 per compute unit.
The free plan includes $5 of usage a month, which Apify says is enough for testing and low volume. Paid plans start at $19 a month on Apify's pricing page.
How do you clean markdown the scraper missed?
Both tools strip the obvious boilerplate. Neither strips everything, and their own sample outputs prove it: Firecrawl's opens with a banner line, Apify's with a skip link and an "On this page" label.
A short pass after scraping catches most of the rest. This is plain Python, no library:
Then apply three rules before anything gets embedded:
- Drop pages whose status code isn't 2xx (Firecrawl's metadata.statusCode).
- Drop near-empty pages. A login wall or a JavaScript shell often converts to a few hundred characters of nothing.
- Drop exact duplicates. Print views, tag pages and trailing-slash variants produce the same markdown under different URLs.
Build your junk list from what you see in your own output. Open ten scraped files and read them. A few minutes of reading beats weeks of wondering why the bot keeps mentioning the newsletter signup.
How should you chunk markdown for RAG?
Split on headings first, then cap the size. That order matters.
A markdown heading marks where one topic ends and the next begins. If you split on a fixed character count instead, a chunk can start halfway through the pricing section and end in the FAQ. Retrieval then returns half an answer.
LangChain's MarkdownHeaderTextSplitter does the heading split and keeps the heading path as metadata. Its docs then pass the result through RecursiveCharacterTextSplitter to cap the size:
The splitter calls come from LangChain's docs. The chunk size, the overlap and the source_url line are my choices for the example, not LangChain defaults, and clean_markdown is the function from the previous section.

Four details make the difference:
- Use split_documents after the heading split, not split_text. LangChain's docs note that overlap only applies inside a section and never crosses a heading boundary.
- Keep the headings in the chunk text with strip_headers=False. The heading tells the embedding what the chunk is about.
- Attach the source URL and page title to every chunk. You'll want citations, and you'll want to delete a page's chunks when it changes.
- Size by tokens, not vibes. OpenAI's vector store defaults to chunks of 800 tokens with 400 overlap, and Anthropic describes chunks of usually no more than a few hundred tokens. Start there, then test with real questions.
Anthropic also reported that adding a short line of document context to each chunk before embedding cut retrieval failures by 35% in their tests. A chunk that starts "Pricing > Team plan" is that idea in its cheapest form.
What usually goes wrong?
Most failures fall into five patterns:
- The markdown is empty or tiny: the page needs JavaScript. In Apify, move from cheerio to playwright:adaptive. In Firecrawl, try waitFor, which adds extra wait time before the scrape.
- The markdown is full of menus: your selectors target the wrong elements. Check them against the page source, since both tools apply them to the HTML, not the markdown.
- The crawl returns zero pages: in Firecrawl, includePaths also applies to the start URL. If the start URL doesn't match, the crawl can come back empty.
- The bill is bigger than expected: no page cap, or a cap far above what you needed. Set limit or maxCrawlPages on every run.
- Answers quote old prices: the cache served a copy up to two days old. Set max_age to 0 for anything time-sensitive.
One more, and it isn't technical. Scraping public pages for your own index is one thing. Republishing them, ignoring the site's terms, or collecting personal data is another. Read my guide on whether web scraping is legal before you point a crawler at a site you don't own.
Frequently asked questions
If you're building inside your own code, start with Firecrawl: scrape five pages, read the markdown, write your junk filter, then crawl with a limit. If you need a whole site crawled on a schedule, start with Apify's Website Content Crawler and the settings above. Either way, read the output before you embed it. Your answers can't be cleaner than the chunks they come from.


