Skip to content
migration.tools
curl to JavaScript fetch

Curl to JavaScript fetch converter

API docs and browser DevTools speak curl; your code speaks fetch. Paste the command and get an async fetch call with headers, body and error handling in place.

curl command

JavaScript fetch

The result appears here as soon as there is input.

Processed on this device. Nothing you paste or drop is uploaded.

How to use it

  1. 1Paste your curl or drop a file onto the input panel.
  2. 2Adjust the options — the result updates as you type.
  3. 3Copy the JavaScript fetch or download it. Drop several files to convert a batch into one ZIP.

What is understood

Method (-X), headers (-H), JSON and form bodies (-d, --data-raw, --data-urlencode, --json), multipart uploads (-F), basic auth (-u), cookies (-b), user agent, referer, bearer tokens, -G query strings, timeouts and redirects.

The command is split the way a shell would, including single and double quotes, backslash line continuations and the $'…' quoting that Chrome and Firefox produce when you copy a request as cURL.

When the body is JSON, it is emitted as a native object rather than an escaped string, so you can edit it straight away.

Questions

How do I copy a request from my browser as curl?

Open DevTools → Network, right-click the request and choose Copy → Copy as cURL. Paste it here. Remove cookies and tokens you don't want in your code first.

Is the command — including my tokens — sent to a server?

No. The command is parsed in your browser. Nothing is transmitted and the request itself is never executed.