cURL to Node.js SuperAgent Converter
Convert curl commands to Node.js code using SuperAgent. Paste a command and the SuperAgent 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 SuperAgent code appears instantly; other Node.js libraries (fetch (built-in), Axios, Got, Ky, node-fetch, request, http) are in the tabs above the code.
- Set up: Install with
npm install superagent. - Run it: Save as
request.mjsand runnode request.mjs. Replace placeholders such asYOUR_TOKENfirst, and check any notes under the editors for curl options that have no SuperAgent equivalent.
Example
GET with headers → Node.js SuperAgent
curl 'https://api.example.com/v1/users?page=2' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN'import superagent from 'superagent';
const response = await superagent.get('https://api.example.com/v1/users?page=2')
.set('Accept', 'application/json')
.set('Authorization', 'Bearer YOUR_TOKEN')
.redirects(0)
.ok(() => true); // resolve for every status, like curl
console.log(response.status);
console.log(response.body);Common use cases
- Existing SuperAgent code
- API tests (it's the base of supertest)
Converting curl to Node.js SuperAgent
SuperAgent is a chainable HTTP client for Node.js and browsers.
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 SuperAgent code. Options that have no SuperAgent equivalent are listed under the editors rather than silently dropped.
Other libraries for Node.js, each with its own page: fetch (built-in), Axios, Got, Ky, node-fetch, request, 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
Why .ok(() => true)?
SuperAgent rejects on 4xx/5xx by default; this resolves every response, like curl.
Why .redirects(0)?
curl doesn't follow redirects unless you pass -L, so the code matches that behaviour.
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.