curl to Node.js Converter
Convert a curl command to Node.js axios code instantly in your browser. The command stays on your device.
Your curl command is converted to Node.js locally in your browser and never uploaded, but avoid pasting real production tokens or credentials into any tool.
Prefer the browser fetch API? Try cURL to Fetch.
About cURL to Node.js (axios)
This curl to node converter rewrites a curl command as a Node.js script built around axios, the request library most Node projects already depend on. As a curl to axios tool it parses flags like -X, -H, -d, --data-raw, --json, -u, -b, and -G, then assembles a config object with method, url, headers, and data so the request is ready to fire. Valid JSON bodies become a real JavaScript object on the data field, which axios serializes and sends with the right Content-Type, while form and raw bodies stay as strings. The snippet calls axios(config) with then/catch handlers that log the status and response, so it drops straight into a script or service. The conversion runs in your browser, so the command and any tokens in it are processed locally on your device and never leave it.
Features
- Builds an axios config object with method, url, headers, and data
- Lowercases the HTTP method the way axios expects it
- Turns valid JSON bodies into a JavaScript object on the data field
- Keeps form-encoded or raw bodies as a string so nothing is double-encoded
- Maps -u/--user to a Basic auth header and handles cookies, user-agent, and referer
- Appends -G/--get data to the URL as a query string
- Adds then/catch handlers that log the status and the response or error
- Copy the result or download it as request.js with one click
How to use the cURL to Node.js (axios)
- Paste your curl command into the cURL command box.
- Read the generated Node.js axios script in the output panel.
- Check the warning banner for any flags that were adjusted or skipped.
- Click Copy, or download the file as request.js.
Example
Input
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name":"Ada"}'
Output
const axios = require('axios');
const config = {
method: "post",
url: "https://api.example.com/users",
headers: {
"Content-Type": "application/json",
},
data: {
"name": "Ada"
},
};
axios(config)
.then((response) => {
console.log(response.status);
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.error(error.response ? error.response.data : error.message);
});
A JSON body becomes a real object on data, which axios serializes for you.
Common errors & troubleshooting
- Running the script throws Cannot find module 'axios'. — Install the dependency first with npm install axios; the generated code uses the third-party axios client.
- You prefer ES modules over require(). — Swap const axios = require('axios') for import axios from 'axios' and set "type": "module" in package.json, or rename the file to .mjs.
- A form body shows up as a quoted string instead of an object. — That is intentional for non-JSON bodies so axios does not re-encode them. Send the request with --json or a JSON Content-Type to get a parsed object.
Frequently asked questions
- How do I convert a curl command to Node.js?
- Paste the curl command into the input box and the converter renders a Node.js axios script on the right that you can copy or download as request.js.
- Does the output use axios or the built-in fetch?
- It uses axios and emits an axios(config) call. Install it with npm install axios first; if you prefer fetch, use the cURL to Fetch tool instead.
- How is a JSON body represented in the axios config?
- A valid JSON body is placed on the data field as a JavaScript object, and axios serializes it and sets the JSON Content-Type when the request runs.
- Will the generated code run on older Node versions?
- Yes. It uses CommonJS require() and axios, so it works on any Node version where axios is installed, without relying on a built-in fetch.
- Is my curl command uploaded when I convert it to Node.js?
- No. The curl to node conversion runs entirely in your browser, so the command and any credentials in it stay on your device.
Related tools
- cURL to Python — Convert a curl command to Python requests code.
- cURL to Go — Convert a curl command to Go net/http code.
- cURL to PHP — Convert a curl command to PHP cURL code.
- cURL to Fetch — Convert a curl command to a JavaScript fetch() call.
- API Request Client — Send HTTP requests, build headers and params, inspect responses — your last 25 requests are saved locally.
- URL Parser — Break a URL into its parts and list query parameters.
All ArrayKit tools