FREE TOOL

curl to JavaScript Converter

Paste a curl command, get working fetch code for the browser or Node.js 18+ — headers, JSON bodies, form data, and timeouts translated. Runs in your browser, no signup.

Conversion runs entirely in your browser — the command (and any tokens or cookies in it) is never sent to a server. Tip: DevTools Network tab → right-click a request → Copy as cURL.

Scraping a real site? Skip the blocks

Hand-copied curl headers go stale, and sites still block datacenter IPs. The same request through the WebScraping.AI API gets rotating proxies, headless Chrome rendering, and unblocking in one call — your custom headers and cookies are forwarded via the headers parameter:

2,000 free API credits · No credit card required

What the generated fetch code does

The output is modern async/await fetch: -H headers become the headers object, a JSON body becomes JSON.stringify(…), form-encoded data becomes URLSearchParams, -F uploads become FormData, -u turns into a Basic Authorization header built with btoa(), and -m maps to AbortSignal.timeout(). The same code runs in browsers and in Node.js 18+, where fetch is built in.

Two fetch-specific caveats the converter flags: browsers own the Cookie header (a cookie-carrying request only works verbatim in Node.js), and fetch has no proxy option — for -x you need Node with undici's ProxyAgent, or axios.

Frequently asked questions

How do I convert a curl command to JavaScript fetch?

Paste the command into the converter above — it outputs fetch code with async/await instantly, in your browser. Headers, JSON and form bodies, basic auth, file uploads, and timeouts are translated. Nothing you paste is sent to a server.

Why does the request work in curl but fail in the browser with a CORS error?

curl isn't subject to the browser's same-origin policy; fetch from a web page is. If the target API doesn't send CORS headers, the browser blocks the response. Run the same code in Node.js 18+ (no CORS there), or route the request through a server-side proxy or scraping API.

Should I use fetch or axios?

fetch needs no dependency and covers most cases — it's the default choice in both browsers and Node.js 18+. axios adds conveniences fetch lacks: automatic JSON parsing, proxy support, interceptors, and wider legacy-Node compatibility. This tool generates both — pick Node.js (axios) in the dropdown.

The fetch code gets a 403 that curl doesn't — why?

Node's fetch has its own TLS fingerprint and your server's IP has its own reputation; anti-bot systems check both, plus JavaScript challenges. Copying more headers rarely fixes it durably. The WebScraping.AI API runs the request through rotating proxies and real headless Chrome instead.

Related

fetch code ready? Make it unblockable.

Same request, plus rotating proxies, headless Chrome, and JS rendering — one API call from JavaScript.

Icon