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

How to use the cURL to Node.js (axios)

  1. Paste your curl command into the cURL command box.
  2. Read the generated Node.js axios script in the output panel.
  3. Check the warning banner for any flags that were adjusted or skipped.
  4. 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

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

All ArrayKit tools