Curl to Fetch
Turn a curl command into JavaScript fetch code, including the method, headers, body and basic login, with quotes handled the way a shell would.
Curl to Fetch converts a curl command into JavaScript fetch code. It reads the method, headers, request body, form fields, basic login, cookies and user agent, and it splits quotes and line continuations the way a shell does.
What is curl, and what is fetch?
curl
A command-line tool for making HTTP requests. API documentation and the browser's "Copy as cURL" option both produce curl commands.
fetch
The standard JavaScript function for HTTP requests in browsers, Node.js, Deno and Bun. It takes a URL and an options object with method, headers and body.
Why use Curl to Fetch?
- From docs to code. Turn an API example into working JavaScript in seconds.
- Quotes handled properly. Single quotes, double quotes, $'...' strings and backslash line breaks are read like bash reads them.
- Readable JSON bodies. A JSON body is turned into JSON.stringify of a real object you can edit.
How to use Curl to Fetch, step by step

- Paste the command into Curl to Fetch. The whole thing, starting with curl.
- Read the generated code. Notes at the end list any options that fetch cannot copy, such as --insecure.
- Copy it into your project. Or download it as a .js file.
Frequently asked questions
Which curl options are supported?
-X, -H, -d, --data-raw, --data-binary, --data-urlencode, --json, -F, -u, -A, -b, -e, -G and -I. Options with no fetch equivalent are listed as notes.
Will the request work from a browser?
The code is correct, but the browser applies CORS rules, and some headers, such as Cookie and User-Agent, cannot be set from a web page. It works as is in Node.js 18 and later.
Is my API key sent anywhere?
No. The conversion happens in your browser and no request is made.
Looking for the long version? The guides cover each of these jobs in depth.