All Tools / Dev Tools / cURL to JavaScript Converter β€” Free Online
Output
cURL Command
JavaScript fetch()

cURL to JavaScript Converter

What this tool does

Paste a cURL command and the converter produces ready-to-run JavaScript. Switch between fetch() and axios with the toolbar chips. The parser extracts the URL, HTTP method, headers, request body, basic auth credentials, cookies, and redirect behavior β€” then maps each to the correct JavaScript API. JSON request bodies are formatted with JSON.stringify for clean output.

How to use

  1. Copy a cURL command from DevTools, Postman, or API docs.
  2. Paste it into the left panel. Conversion runs automatically.
  3. Choose fetch() or axios from the toolbar.
  4. Click Copy to copy the generated JavaScript.

Frequently Asked Questions

What cURL flags does this converter support?

The converter handles the most common flags: -X (method), -H (headers), -d/--data/--data-raw/--data-binary (request body), -u (basic auth), -b (cookies), -L (follow redirects), -A (user agent), and --compressed. Unknown flags are ignored.

Where do I get a cURL command?

Browser DevTools: open the Network tab, right-click any request, and choose Copy > Copy as cURL. Postman: click the code icon and select cURL. API documentation often includes cURL examples directly.

What is the difference between fetch() and axios?

Both make HTTP requests in JavaScript. fetch() is built into modern browsers and Node.js 18+ β€” no install needed. axios is a popular library that adds automatic JSON parsing, request/response interceptors, and better error handling. Use fetch() for simple cases; use axios in projects that already have it installed.

Does the converter handle multiline cURL commands?

Yes. cURL commands split across lines with backslash continuation (\) are joined before parsing. Paste the entire command including line continuations.

Is this converter secure?

Yes. Parsing runs entirely in your browser. No cURL commands or API keys are sent to any server.