Skip to main content
NyankoTools

cURL to Fetch / Axios Converter

Paste a curl command and get the equivalent fetch or axios code. Handy for turning the curl examples in API docs, or a curl command copied from your browser DevTools, into working JavaScript. The command is only parsed — no request is ever made. To inspect or pretty-print a JSON request body, try the JSON Formatter as well.

🔒 Runs in your browser · Your data is never sent to a server

Output format

How to use

  1. Paste your command into the "curl command" box (multi-line commands with a trailing "\" work too).
  2. Pick fetch or axios under "Output format".
  3. Click "Copy" on the result and paste the code into your project.

Notes

  • The main options are converted: -X, -H, -d / --data-*, --json, -F, -u, -A, -e, -b, -G, -I, and --url. Any other option is ignored and a warning is shown.
  • File references such as -d @filename or -F field=@filename cannot be read in the browser, so you need to replace them in the result yourself.
  • The Cookie, User-Agent, and Referer headers cannot be set from fetch or axios in a browser (Node.js allows them). In a browser you also need the right CORS settings on the server.
  • This tool only parses the command and generates code; it never runs curl or calls any API. Your input is not sent to a server, but if the command contains tokens or other secrets, check the generated code before you share or publish it.

Glossary

cURL

A command-line tool for transferring data over HTTP and other protocols from a URL. API documentation often uses it for request examples.

fetch

The built-in HTTP request API in browsers and Node.js 18+. It needs no extra library and is Promise-based.

axios

A JavaScript HTTP client library that works in both the browser and Node.js. It makes automatic JSON handling and basic auth easy.

CORS

A mechanism where the server uses response headers to say whether a browser may call it from another origin. A request that works with curl can still fail in browser fetch or axios if CORS is not configured.

FAQ

Can I convert "Copy as cURL" from my browser DevTools?

Yes. Paste the command from "Copy as cURL (bash)" in Chrome or Firefox DevTools as-is. The Windows "Copy as cURL (cmd)" format uses different quoting, so copy the bash version instead.

How is a JSON body converted?

If the Content-Type is JSON and the body is valid JSON, fetch gets JSON.stringify({...}) and axios gets an object in data. If the body cannot be parsed as JSON, it is output as a plain string.

Are all curl options converted?

The main ones are: method, headers, data, form fields, basic auth, cookie, User-Agent, Referer, -G, and -I. Options that fetch and axios cannot express with basic syntax, such as timeouts and proxies, are ignored and a warning is shown.

Why does the converted code hit a CORS error in the browser?

curl is not a browser, so CORS does not apply to it, but browser fetch and axios are blocked unless the target server allows your origin. Configure CORS on the server, or run the code in a server environment such as Node.js.

Share this page

↑↓ Select Enter Open Esc Close