← Tutorials
BUILD · DATA · 10 MIN

Scrape a web page into JSON

A page full of messy products, and a clean JSON file with the name and price of each one. No hand-written scraper. You describe it to Firecrawl in one sentence and it hands it back structured.

For
anyone who needs data off a web page without coding a scraper
Needs
Node, a Firecrawl API key, and knowing how to store it without leaking it
Time
10 minutes

Scraping a page by hand is fragile: you write selectors, the page changes, it breaks. Firecrawl flips it around: you tell it what data you want in plain language and an agent reads the page and hands it back as JSON. We'll pull a product list off a shop, but it works for any data: prices, listings, directories, profiles.

MESSY PAGE menus, noise, HTML FIRECRAWL you describe it CLEAN JSON only your fields
No selectors, no scraper. You name the fields you want; the agent reads the page and returns them.

Why this holds up where a normal scraper doesn't: a hand-written scraper depends on the page's exact structure, so the day they rename a class, it breaks. The agent reads the page the way you would, by meaning. Change the layout and it still finds the price, because you asked for "the price," not for div.col-3 > span.amount.

1. Install the CLI and sign in

Firecrawl has a command-line tool. Install it with Node and authenticate:

npm install -g firecrawl-cli

Check it's ready. If you're missing the key, the command walks you through creating it at firecrawl.dev (the free plan gives you plenty of credits to start). Store it in a .env like any other key, never in the code: it's covered in your first API key, without leaking it.

firecrawl --status
● Authenticated
  Credits: 500,000 remaining

2. First, see what's on the page

Before extracting anything, scrape the page to see its clean content. This hands back the page in markdown, no menus, no noise:

firecrawl scrape https://example-shop.com/products -o page.md

Open page.md and check the data you want is in there. If it shows up, the agent will be able to extract it.

3. Ask for the data as JSON

Now the good part. The agent command takes a sentence with what you want and the URL, and hands back JSON. --wait waits for it to finish and --pretty makes it readable:

firecrawl agent "extract each product with its name and price" \
  --urls https://example-shop.com/products \
  --wait --pretty -o products.json

And products.json comes out like this, ready to use anywhere:

[
  { "name": "Nordic Chair",  "price": 89.00 },
  { "name": "Oak Table",     "price": 240.00 },
  { "name": "Floor Lamp",    "price": 65.50 }
]

4. Want more precision? Give it a schema

The sentence is enough for most cases. If you need the fields to come out exact every time (same names, same types), pass a schema with --schema:

firecrawl agent "extract the products" \
  --urls https://example-shop.com/products \
  --schema '{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"price":{"type":"number"}}}}' \
  --wait --pretty -o products.json

When something breaks

The usual snags, and the fix for each:

Now try this

Same command, more reach:

What you just did

You turned a web page into data you can use, without writing or maintaining a scraper. What you asked for was products, but the same command pulls a competitor's prices, a directory's listings, or any data that shows up on a page. The work stopped being coding the scraper; now it's just saying what you want.

FOUND THIS USEFUL? GET THE NEXT ONE

Drop your email and I'll ping you when the next build goes up, with the code and prompts I used. No spam.

More tutorials ↗