cURL to Fetch

Convert a curl command to a JavaScript fetch() call.

Your curl command is converted locally in your browser and never uploaded, but avoid pasting real production tokens or credentials into any tool.

Inspecting an API URL? Try the URL Parser.

About cURL to Fetch

This curl to fetch converter takes a curl command you copied from your terminal, browser DevTools, or API docs and rewrites it as a ready-to-run JavaScript fetch() call. As a curl to fetch converter it parses common flags like -X, -H, -d, --data-raw, --json, -u, -b, and -G, infers the right HTTP method, sets sensible Content-Type headers, and pretty-prints JSON bodies with JSON.stringify. Use it to move a curl request into front-end code, a Node script, or a quick test without hand-translating syntax. It is built for developers, QA engineers, and anyone wiring up API calls who wants a fast curl to javascript translation. The conversion runs entirely in your browser, so the command you paste is processed locally and never leaves your device.

Features

How to use the cURL to Fetch

  1. Paste your curl command into the cURL command box.
  2. Read the generated fetch() equivalent in the output panel on the right.
  3. Check the warning banner for any flags that were ignored or adjusted.
  4. Click Copy to grab the fetch code, or download it as request.js.

Example

Input

curl https://api.example.com/users \
  -H "Authorization: Bearer TOKEN" \
  -d '{"name":"Ada"}'

Output

const response = await fetch("https://api.example.com/users", {
  method: "POST",
  headers: {
    "Authorization": "Bearer TOKEN",
    "Content-Type": "application/x-www-form-urlencoded"
  },
  body: "{\"name\":\"Ada\"}",
});

const data = await response.text();

A -d body defaults to POST with a form-urlencoded Content-Type.

Common errors & troubleshooting

Frequently asked questions

What is the cURL to Fetch converter?
It is an in-browser tool that parses common curl flags including -X, -H, -d and its variants, --json, -u, -b, -A, -e, -G, and --url, then builds an equivalent JavaScript fetch() call with the right method, headers, and body.
How do I convert a curl command to fetch?
Paste your curl command into the input box and the cURL to Fetch converter instantly renders the fetch() equivalent on the right, which you can copy or download as request.js.
How does the cURL to Fetch converter decide the HTTP method?
If you pass -X or --request it uses that; otherwise it defaults to POST when a data body is present and GET when there is none.
Does it handle basic auth from -u and -G query data?
Yes. A -u or --user value is base64-encoded into an Authorization: Basic header, and with -G your -d data is appended to the URL as a query string while the request body stays empty, just like curl.
Is my curl command sent anywhere when I convert it?
No. The curl to fetch conversion runs entirely in your browser, so the command and any tokens in it are processed locally and never leave your device.

Related tools

All ArrayKit tools