AZ Tools

cURL to fetch / axios Converter

Developer

Parses cURL flags (`-X`, `-H`, `-d`, `--json`, `-u`, `-A`, `-b`, …) and emits a clean JS request. Pick `fetch` for the platform built-in or `axios` for the npm library. Multi-line continuations and quoted strings work, so you can paste browsers' "Copy as cURL" output straight in.

Target:
JS code
const response = await fetch("https://api.example.com/v1/users", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer abc123",
  },
  body: "{\"name\":\"Alice\",\"role\":\"admin\"}",
});
const data = await response.json();

How to use

  1. Paste the cURL command in the input box.
  2. Pick `fetch` or `axios` to match your target.
  3. Copy the resulting code into your file.

Frequently asked questions

Where can I get a cURL command to paste?
Chrome / Firefox / Safari DevTools → Network tab → right-click any request → Copy → Copy as cURL. Postman and Insomnia have a similar export.
Does it understand `--json`?
Yes. `--json` shorthand sets the body and adds the `Content-Type: application/json` and `Accept: application/json` headers if you didn't set them already.
What about `-L`, `-s`, `-v`?
Flags that don't change the request payload are ignored — `fetch` and `axios` already follow redirects by default, and verbose output is a CLI-only concern.
Why does axios output put the body as `data:`?
axios uses `data` for request bodies, and if the body parses as valid JSON the converter emits it as a JS object literal. If it doesn't parse, it falls back to a string.

Related tools