curl to Axios Converter – Free, Online, Private
Turn a curl command into an Axios call. Headers, JSON bodies, basic auth, and form fields are mapped without sending the command anywhere.
How to convert curl to Axios
- Paste a curl command, including one you copied from a browser's network panel.
- Read the Axios snippet. The method is lowercase and a JSON body is a JavaScript value, not a string.
- Copy it into a module that already imports Axios, and replace file placeholders if the command used -F.
What is parsed
The command is tokenized before it is interpreted. Single quotes, double quotes, and $'...' ANSI-C quotes are honored, and a backslash at the end of a line is a continuation rather than a character in the URL. That matters because copied curl is almost always wrapped. -X sets the method. -H and --header split on the first colon. -d, --data, --data-raw, and --json become the body. --json also adds the JSON content type and Accept header when they are missing. -u becomes an auth object with username and password. -F becomes FormData, and a @file field is noted as a createReadStream placeholder rather than opened. -k is not silently dropped: the parser records insecure, though the Axios snippet does not disable TLS verification for you, because that is a bad default to hide in a one-liner.
How the Axios call is shaped
The snippet imports axios and awaits axios({ method, url, headers, data }). The method is the lowercase name Axios expects. A JSON body is pretty-printed as a JavaScript object in data, so Axios will serialize it and set the content type if you have not set one yourself. A non-JSON body stays a string. Headers are copied as you wrote them, aside from a content type that -F would contradict. Basic auth uses the auth option rather than a hand-built Authorization header, so Axios does the Base64 step. Query strings that were already in the URL stay in the URL. -G, which moves -d into the query string, is applied before the snippet is built. A missing URL is an error. A command that does not start with curl is an error.
Worked example
The sample is a POST to https://api.example.com/v1/users with an Authorization bearer header, a JSON content type, and a body naming Ada Lovelace as an admin. The backslash continuations are removed by the tokenizer, so the URL is not parsed as if it contained a newline. The Axios data object has name and role. The bearer token is copied into the headers exactly. If the token is a real production token, it is still only in your tab: the converter does not post the command. Replace TOKEN before you commit the snippet. A browser 'Copy as cURL' often includes cookies and client hints. Those headers are preserved. Delete the ones the API does not need. The sibling fetch converter is the same parse with a different printer.
Limits
Shell variables are not expanded. $TOKEN stays the characters dollar, T, O, K, E, N, because this is not a shell. File bodies such as -d @payload.json are kept as the literal text and called out in a warning rather than read from your disk. --compressed, retries, proxies, and -o output files are not mapped onto Axios config. Multipart files assume Node's fs module when a @file was present. Browser Axios would use a File from an input instead. Timeouts are not invented. If you need a timeout, add it in Axios yourself. For a Go net/http program or a PHP curl script from the same command, use the other curl pages. They share this parser.
Frequently asked questions
Does Axios receive a JSON string or an object?
An object when the body is JSON, so Axios serializes it. Other bodies stay strings.
Are line continuations supported?
Yes. A trailing backslash followed by a newline is whitespace, which is how wrapped curl is copied.
Will my Authorization header be uploaded?
No. Parsing runs in the browser. The page is a static file.
What about -k?
The flag is recognized and not turned into a hidden TLS bypass in the snippet. Add that config yourself if you really mean it.