CURL to Fetch/Axios Converter

Convert curl commands into fetch, Axios, and other client snippets. Free online curl-to-code tool for developers.

Tool input stays in your browser. The site may use cookies for ads.

How common flags map

curl -X POST 'https://api.example.com/v1/items' \
  -H 'Authorization: Bearer TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{"name":"widget"}'

// fetch sketch
fetch('https://api.example.com/v1/items', {
  method: 'POST',
  headers: {
    Authorization: 'Bearer TOKEN',
    'Content-Type': 'application/json',
  },
  body: '{"name":"widget"}',
});
  • -H → headers
  • -d / --data / --data-raw → body (string)
  • -F → multipart FormData
  • -u user:pass → Authorization Basic header
  • --compressed → Accept-Encoding handling (browsers often negotiate this automatically)
  • -k / --insecure → no browser equivalent; you cannot disable TLS validation in fetch

Multipart vs urlencoded

-d a=1&b=2 is typically urlencoded. -F file=@x.png is multipart. Mixing them incorrectly is a common source of 400s after conversion — keep the body type you actually used in curl.

What cannot convert cleanly

Shell-only features (process substitution, env expansion quirks), custom TLS, HTTP/2 prioritization knobs, and binary stdin pipes often need manual cleanup. Always re-test auth headers — browsers may block forbidden header names.

Frequently Asked Questions

Why did -d become application/x-www-form-urlencoded?

curl defaults that Content-Type when you pass -d/--data without an explicit -H Content-Type. fetch needs the header set explicitly if you send a urlencoded body string.

Can it convert cookie jars and mutual TLS?

Browser fetch cannot do arbitrary client certificates or curl's cookie-jar file semantics. Those parts need Node, a backend proxy, or stay as curl.

What about --data-raw vs -d?

--data-raw does not expand @file references the way -d can. Converters usually treat the string as the literal body.

Related Tools