cURL to Axios
Convert a curl command to an Axios request
About cURL to Axios
Paste a cURL command to get a single axios({ method, url, headers, data }) call that awaits the response and destructures data. JSON bodies are written as plain JavaScript objects, -F fields are appended to FormData, and -u becomes a Basic Authorization header. The snippet imports the Axios package from npm, while the conversion itself runs locally without contacting a server.
Category: API.
Frequently asked questions
Do I need to install Axios to run the generated code?
▾
Yes. The snippet starts with import axios from 'axios', so add the package with npm install axios or your package manager's equivalent. It makes one awaited axios({ method, url, headers, data }) call and destructures data, which Axios parses automatically when the response is JSON.
How does the Axios output represent JSON and form bodies?
▾
A JSON -d payload is written as a JavaScript object in data, and Axios serializes it to JSON for you. Other -d payloads, URL-encoded ones included, stay as strings, and -F fields are appended to a FormData object that is passed as data.
Does the Axios code use the auth option for -u credentials?
▾
No. -u user:pass becomes an Authorization: Basic header with the Base64 value precomputed, placed next to any -H headers. You can replace it with Axios's auth: { username, password } option, which produces the same header.
Which cURL flags are left out of the Axios request?
▾
-k, -L, -b, -A, --compressed and timeout or proxy flags are not translated. Axios already follows redirects, and you can add timeout, extra headers or an httpsAgent to the config if the command relied on the others.