Advertisement

cURL to Axios

Paste a cURL command and convert it into Axios request code. Method, URL, headers, body and auth map to the matching axios call signature.

cURL to Axios

Paste a cURL command below.

Advertisement

How the conversion works

The parser extracts the method, URL, headers and body from the cURL command, then emits the matching axios method call. GET style requests put headers in the config object, while POST style requests pass the body as the second argument and config as the third.

Why Axios over fetch

Axios adds interceptors, automatic JSON transforms, request cancellation and better error objects on top of fetch. Converting cURL examples to Axios gives you code that drops straight into most existing codebases.

cURL to Axios FAQs

Which cURL flags are supported?
-X/--request, -H/--header, -d/--data variants, -u/--user, -A/--user-agent and --url are parsed. Basic auth also becomes the axios auth config for convenience.
How is basic auth handled?
The -u user:pass flag becomes both an Authorization header and the axios auth: { username, password } option, so you can delete whichever form you do not need.
What about query parameters?
Parameters already in the URL are kept as written. For -G with -d, append the fields to the URL query string manually.
Is the request executed?
No. The tool only generates code. Nothing runs and no network request is made until you execute the code yourself.
Is my command uploaded?
No. Parsing runs entirely in your browser, so tokens and API keys never leave your device.
Advertisement