ScrapeNinja
Tool / Converter

Convert cURL to JavaScript web scraper

Turn a cURL command into Node.js code that runs the request through ScrapeNinja, with a real Chrome fingerprint, proxies and retries.

  • Removed headers: user-agent
  • The request sends cookies. Check they don't contain your session or account ID.

Node.js 18+ (built-in fetch). Run as an ES module: node scraper.mjs. Get a key on APIRoad or RapidAPI (free plans available). Want to try it first? Open the playground.

Why convert cURL to a Node.js scraper?

While scraping, the quickest way to reproduce a request is to open the Network tab of the browser DevTools, right-click the request and choose Copy as cURL. The command works from your terminal, but sent from a server it usually gets blocked: the TLS fingerprint of cURL or of a Node.js HTTP library is nothing like Chrome's, and the IP of a datacenter is easy to spot.

This converter keeps the URL, method, headers and body of your request and sends it through the ScrapeNinja API instead: with the network fingerprint of a real Chrome, rotating proxies in the country you choose, and automatic retries from another IP when the site pushes back.

Running the Node.js scraper

The code uses the built-in fetch of Node.js 18 and newer, so there is nothing to install. Save it as scraper.mjs (the .mjs extension enables top-level await), put your API key instead of YOUR_KEY, and run node scraper.mjs.

Which headers to keep

  • Cookies may contain your session ID or other data that ties every request to your account, and they expire. Keep them only if the site really needs a logged-in session (see scraping as an authenticated user).
  • User-Agent is better left to ScrapeNinja: it sends the one that matches the Chrome fingerprint it emulates. A User-Agent from another browser version is a common reason to get blocked.
  • Accept-Language, Referer and API-specific headers (tokens, x-requested-with) are usually worth keeping.

Video overview