Convert cURL to axios

Paste a curl command to get an axios request config — params, headers, data and auth mapped for you.

AI DevRuns in your browser — nothing uploaded

Output language

Converted in your browser — tokens and passwords in the command never leave your device. Tip: in Chrome DevTools, right-click a request in the Network tab → Copy → Copy as cURL.

How curl options map to axios

axios takes one config object, so each part of the curl command has a clear place to go.

  1. The query string becomes params. axios encodes it and adds it to the URL, so you can change values without touching the URL.
  2. The body goes in data. A plain object is sent as JSON with the JSON Content-Type; URLSearchParams is sent as a form.
  3. -u user:pass becomes auth: { username, password }.
  4. --max-time 10 becomes timeout: 10000 — axios counts in milliseconds and has no timeout unless you set one.
  5. -F becomes a FormData object in data; axios adds the multipart boundary.
  6. -k becomes an httpsAgent with rejectUnauthorized: false, and -x becomes the proxy option. Both only work in Node.

Unlike fetch, axios throws for any status outside 200–299. Wrap the call in try/catch and read error.response.status and error.response.data, or pass validateStatus: () => true to handle every status yourself.

Example: curl to axios

This command, pasted into the converter above, gives the code below.

cURL command
curl -G https://api.example.com/v1/invoices \
  -u 'YOUR_KEY_ID:YOUR_SECRET' \
  -d status=unpaid \
  -d limit=25 \
  --max-time 10
axios
import axios from "axios";

const response = await axios({
  method: "get",
  url: "https://api.example.com/v1/invoices",
  params: {
    status: "unpaid",
    limit: "25",
  },
  auth: { username: "YOUR_KEY_ID", password: "YOUR_SECRET" },
  timeout: 10000,
});

console.log(response.status);
console.log(response.data);

How it works

  1. 1

    Reads the command like a shell

    Single and double quotes, $'…' strings, backslash line breaks and Windows ^ escapes are all understood — so Chrome’s “Copy as cURL (bash)” and “(cmd)” both work.

  2. 2

    Understands curl’s options

    -X, -H, -d, --data-raw, --data-urlencode, --json, -F, -u, -b, -G, -k, -L, -x, --max-time and more — with curl’s own defaults, like POST when there’s a body.

  3. 3

    Writes idiomatic code

    json= in Python, URLSearchParams and FormData in JavaScript, a multipart writer in Go, CURLFile in PHP and a text block in Java — the way each language would normally do it, using only what ships with it where possible.

  4. 4

    Tested against real curl

    Code in all seven languages was run against a test server and checked to send the same method, URL, headers and body as curl itself.

Questions, answered

Yes. axios({ method: "get", url, params }) and axios.get(url, { params }) send the same request. The converter uses the config form so every method looks the same; switch to the shortcut if you prefer it.

Popular uses

Read the guide