cURL to Axios Converter
Convert cURL commands to Axios.js JavaScript code. Supports headers, request body, auth, cookies, and all common cURL flags.
Looks like this contains credentials. They are converted in this tab only — not uploaded, and not included in the link that Share or Copy link produces.
About cURL to Axios Converter
cURL is the universal command-line HTTP client, but Axios is often preferred in JavaScript and Node.js projects for its promise-based API and interceptor support. This converter parses your cURL command and generates the equivalent Axios call — including headers, JSON body (formatted as a JS object), basic auth via the auth option, and cookies. Paste any cURL command copied from browser DevTools or API documentation and get ready-to-use Axios code instantly.
Built and maintained by Meet Shah · Last updated
What this tool is used for
- Turning a curl command from an API's docs into code you can paste into a Node service.
- Reproducing a request captured from DevTools inside an existing Axios client.
- Getting the header and body shape right before wiring in interceptors.
- Converting a working curl into a test fixture for an Axios-based client.
- Checking which curl flags have no Axios equivalent before you rely on them.
Frequently Asked Questions
- How does axios error handling differ from fetch?
- The opposite way round: axios REJECTS on any status outside 2xx, so a 404 lands in catch. fetch resolves. Override with validateStatus: () => true if you want axios to resolve on every status, which is closer to curl's default behaviour.
- What is the difference between data and params?
- params becomes the URL query string (curl's -G or a ?a=b suffix); data becomes the request body (curl's -d). Passing query values in data on a GET silently sends nothing, because axios omits GET bodies.
- Does axios serialise JSON automatically?
- Yes. Passing a plain object as data sets Content-Type: application/json and stringifies it — unlike fetch, which requires JSON.stringify. For form-encoded bodies matching curl's plain -d, pass a URLSearchParams instance instead.
- How do I set a default header for every request?
- axios.defaults.headers.common['Authorization'] = token, or create an instance with axios.create({ baseURL, headers }). Interceptors let you attach or refresh auth per request — there is no curl equivalent, since curl has no persistent client object.
- Where does the response body live?
- In response.data, already parsed. fetch requires an explicit await response.json(). This trips people porting between the two: axios response.json() does not exist and returns undefined.
Common errors and gotchas
- Forgetting Axios rejects on a 4xx or 5xx, unlike curl and unlike fetch — error handling has to change shape.
- Passing a JSON body as `data` without a content-type, which Axios then guesses from the value's type.
- Assuming `-k` maps cleanly, when disabling TLS verification in Axios needs an https agent rather than a flag.
- Losing cookies, since curl's jar has no equivalent — Node needs an explicit cookie jar wrapper.
- Expecting `--compressed` to matter, when Axios and Node handle encoding without being told.