gizmobench
BrowseDaily

cURL to Axios

This page selects Axios output for a supported bash-style curl command. The generated JavaScript imports axios and builds a request configuration with the method, URL, headers and inline body. Text form fields can become FormData. Conversion never sends a request. Inspect the notes before using the source, especially for browser-controlled headers, JSON body transforms, redirects or Node-only handling of certificate checks.

method    POST, set by -d
url       https://api.example.com/v1/notes
headers   2
  Content-Type: application/json
  X-Request-Label: weekly report draft
body      38 bytes
errors    none: no unsupported flags
notes
  - Without -L curl stops at a redirect, and this code follows it, as Axios does by default.
Axios
import axios from "axios";

const response = await axios({
  method: "POST",
  url: "https://api.example.com/v1/notes",
  headers: {
    "Content-Type": "application/json",
    "X-Request-Label": "weekly report draft"
  },
  data: "{\"title\":\"Weekly report\",\"done\":false}"
});
converted as text: nothing is run, read from disk or sent
Method
POST, from -d
Headers
2
Body
38 bytes
Code
Axios

The command is converted in this tab. It is never saved, sent or added to analytics, and that matters because a pasted command often carries an Authorization header, a -u password or a session cookie. The page remembers only the language you picked, and Start over above the tool forgets it.

Examples

  • -H 'X-Request-Label: weekly report draft'a quoted header with spaces
    one header, X-Request-Label: weekly report draft
  • -X PUT with -d 'qty=3'an explicit method and data
    method PUT, body qty=3; without -X the same -d would be POST
  • $(cat token.txt), a backtick, or -d @body.jsonshell interpolation or a file reference
    3 problems flagged and not converted: nothing is run or read

What each flag becomes

curl flagIn the code
-X, --requestthe method, as written
-H, --headera header; 'Name;' sends it with an empty value
-d, --data, --data-asciithe body and POST, with curl's form Content-Type when none is set; @file is refused
--data-rawthe body, with a leading @ sent as written
--data-binarythe body as written; @file is refused
--data-urlencodea percent-encoded part; name=value encodes only the value
--jsonthe body, with JSON Content-Type and Accept headers
-F, --form-stringtext fields of a multipart form; file parts are refused
-G, --getthe data moved into the URL's query
-I, --heada HEAD request
-u, --userBasic auth: a header in JavaScript, and auth= in requests when the name and password are ASCII
--oauth2-beareran Authorization: Bearer header
-A, -e, -bUser-Agent, Referer and Cookie headers; -b with a file name is refused
-m, --max-timea timeout in each library's own terms
-L, --locationredirects followed, the libraries' default, with allow_redirects=True for a HEAD request in requests
-k, --insecureverify=False in requests, an https.Agent in Axios; an error for Fetch
--compressednothing extra: the libraries ask for compressed responses by default
-s, -S, -v, -i, -o, -w, --faillisted as ignored: they change only curl's own output
-x, --proxy and any other flagan error that names the flag
Accuracy. Converts the text of one curl command, up to 64 KB, and never runs shell interpolation, reads a local file or sends the request, so $( ), backticks, variables and @file references are errors. Flags it does not convert are named as errors too, apart from flags that change only curl's own output, such as -s, -o and --fail, which are listed as ignored. The code carries the method, URL, body and every header the command sets, with -d meaning POST unless -X names another method, escaped for the chosen language.

Common questions

How do I convert curl headers and JSON data to Axios?
Paste the command and the selected Axios output shows its configuration. Supported -H headers and inline body flags are converted; --json adds the corresponding headers unless supplied explicitly. The converter reports unhandled flags instead of omitting them silently.
Can the Axios result run in a browser or Node?
Some requests work in either environment, but the converter cannot establish that for your URL. Browser CORS and forbidden-header rules apply, and a browser drops GET/HEAD bodies. -k is represented by a Node https.Agent and cannot disable certificate checks in a browser. Relevant differences appear in the notes.
Will it send the same bytes for a JSON body?
The converter keeps inline body text. When Axios would otherwise trim or re-encode JSON text, the generated configuration includes a transformRequest override. Duplicate headers, library defaults and multipart boundaries can still differ; review the source and notes rather than assuming complete curl equivalence.
Can I convert Axios back to curl?
No. This page accepts curl text and produces Axios source. It does not parse existing Axios programs, send the generated request or install the axios package.

Converts the text of one curl command, up to 64 KB, and never runs shell interpolation, reads a local file or sends the request, so $( ), backticks, variables and @file references are errors. Flags it does not convert are named as errors too, apart from flags that change only curl's own output, such as -s, -o and --fail, which are listed as ignored. The code carries the method, URL, body and every header the command sets, with -d meaning POST unless -X names another method, escaped for the chosen language.