cURL to Node.js Converter
Convert curl commands to Node.js code using fetch (built-in), Axios, Got, Ky, node-fetch, request, SuperAgent or http. Paste a command and the Node.js snippet appears instantly — everything runs in your browser.
- Instant ConversionCode updates as you type
- Multiple Languages40 languages, 61 libraries
- 100% Client SideYour data stays private
How to use this tool
Steps for using the cURL to Code.
- Copy a curl command — from API documentation, or from your browser's DevTools (Network tab → right-click a request → Copy as cURL (bash)).
- Paste it into Enter cURL command. The Node.js fetch (built-in) code appears instantly; other Node.js libraries (Axios, Got, Ky, node-fetch, request, SuperAgent, http) are in the tabs above the code.
- Set up: Use Node.js 18 or later — nothing to install.
- Run it: Save as
request.mjs(top-level await needs an ES module) and runnode request.mjs. Replace placeholders such asYOUR_TOKENfirst, and check any notes under the editors for curl options that have no fetch (built-in) equivalent.
Example
GET with headers → Node.js fetch (built-in)
curl 'https://api.example.com/v1/users?page=2' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN'const response = await fetch('https://api.example.com/v1/users?page=2', {
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer YOUR_TOKEN'
}
});
const data = await response.json();
console.log(response.status, data);Common use cases
- Node scripts and serverless functions
- Code shared with the browser
Converting curl to Node.js fetch (built-in)
Node.js 18 and later include the Fetch API globally, so no package is needed.
The converter reads the curl command the way curl does — the method (-X), headers (-H), request bodies (-d, --data-raw, --json, -F), query strings, basic auth (-u) and cookies — and writes the equivalent fetch (built-in) code. Options that have no fetch (built-in) equivalent are listed under the editors rather than silently dropped.
Other libraries for Node.js, each with its own page: Axios, Got, Ky, node-fetch, request, SuperAgent, http.
Limitations
- The code is a starting point: add timeouts, retries and error handling for production use.
- Secrets in the curl command are copied into the code — move them to environment variables before committing.
Frequently asked questions
Which Node.js version has fetch?
Node.js 18 and later. For older versions, use the node-fetch package.
Why .mjs?
The code uses top-level await, which works in ES modules (.mjs or "type": "module").
Is my curl command sent to a server?
No. The conversion runs entirely in your browser, so tokens and passwords in the command never leave your device. Still, replace real secrets before sharing the generated code.