Free curl to JavaScript (fetch) Converter

Convert a curl command to JavaScript fetch code for the browser or Node.js. See which headers and options fetch cannot send before you run it.

Loading tool…

How it works

Copy the request as cURL

In Chrome, Edge or Firefox DevTools, right-click a request in the Network panel and choose Copy as cURL. On Windows, pick the bash or POSIX version.

Pick browser or Node

Browser code leaves out what a page cannot send and says why. Node code keeps your headers and reads -F files from disk.

Run it

Copy or download it. Run browser code in the DevTools console or a module script. Node 18 and later have fetch built in; the .mjs file allows top-level await.

What can a browser fetch not send?

Headers the Fetch standard forbids are dropped without an error: Cookie, Host, Referer, Origin, Accept-Encoding, Content-Length and any sec- or proxy- name. Chrome also replaces User-Agent (tested in Chrome 157). A request to another site needs that site's CORS permission.

Source: Fetch standard: forbidden request headers · MDN: CORS

What happens to redirects?

curl follows redirects only with -L; fetch follows them by default. Without -L, Node code sets redirect: "manual" and returns the 3xx as curl does. Browser code keeps following, because there "manual" returns status 0 with no Location header.

Source: MDN: RequestInit redirect

Which curl options are converted?

-X, -H, -A, -e, -b, -u, -d, --data-raw, --data-binary, --data-urlencode, --json, -F, -G, -I, -L, -m, --url, --url-query and --oauth2-bearer. -k, -x and --digest have no fetch option and are flagged. JSON bodies are sent exactly as typed, so big numbers keep every digit.

Is my command sent anywhere?

No. Conversion runs in this tab and the command is not sent to a server. Copied commands often carry session cookies and tokens, so treat the code like a password.

Request blocked?

Browser Use cloud browsers run a maintained Chromium fork with residential proxies.