toolqik

58 · API & Webhooks

cURL to Fetch Converter

Turn any curl command into JavaScript fetch() code.

Runs in your browser
fetch

  

About this tool

API docs and browser DevTools give you curl; your app needs JavaScript. This converter reads a curl command, including Chrome and Firefox “Copy as cURL” output, and writes the equivalent fetch() call, with headers as an object, JSON bodies as readable JSON.stringify(…), form uploads as FormData, and Basic credentials encoded for the Authorization header.

Supported curl options

-X, -H, -d / --data / --data-raw / --data-binary / --data-urlencode, --json, -F (multipart), -u (Basic auth), -b (cookies), -A, -e, -G, -I, -L, -k and combined flags like -sSL. Bash quoting, $'…' strings and line continuations work, and so does Chrome DevTools’ “Copy as cURL (cmd)” output for Windows. Options without an equivalent, like -o or -v, are listed so nothing is silently lost.

Copy a request from the browser: open DevTools → Network, right-click a request → Copy → Copy as cURL, and paste it here.

fetch() differences from curl

  • Redirects: fetch follows them by default, curl only with -L; the code sets redirect: 'manual' to match.
  • Errors: fetch only rejects on network failures, not HTTP errors, so check response.ok, as the generated code does.
  • In browsers: the API must allow your site via CORS, and some headers (Cookie, User-Agent, Host) can’t be set. In Node.js 18+, fetch is built in and these limits don’t apply.

FAQ

How do I convert curl to fetch?

Paste the curl command above. The fetch code appears instantly, ready to copy into your JavaScript or TypeScript.

Does it work with “Copy as cURL” from Chrome?

Yes, both the Bash version and the Windows cmd version (with ^ line breaks).

Why does the fetch code fail in my browser but curl works?

Usually CORS: the API doesn’t allow requests from your website. Call it from your server, or configure the API to allow your origin.

Does the generated code run in Node.js?

Yes. Node.js 18 and later include fetch; the code works as-is inside an async function or ES module.

esc
↑↓ navigate↵ open