HTTP vs HTTPS
The generated snippet imports node:https.
Fix: Swap to node:http if the URL is plain HTTP.
header • up to 320x100 / 728x90
Convert a curl command into Node.js https module code ready to paste into scripts or CI
Output will appear here...
content bottom • up to 300x250
sidebar • 160x600
Last reviewed:
JavaScript is the programming language of the web, running in every modern browser and powering most interactive frontends and Node.js backends.
curl to Node.js Converter parses your curl command and produces an equivalent Node.js snippet using the built-in `node:https` module, including URL parsing, header setup, body writes, and basic error handling.
It's ideal when you need a portable Node script that doesn't depend on fetch (e.g. on Node < 18) or on third-party HTTP libraries.
curl https://api.example.com/users -H "X-Key: abc"
import https from "node:https";
import { URL } from "node:url";
const target = new URL("https://api.example.com/users");
const options = {
hostname: target.hostname,
port: target.port || (target.protocol === "https:" ? 443 : 80),
path: target.pathname + target.search,
method: "GET",
headers: {
"X-Key": "abc"
},
};
const req = https.request(options, (res) => {
const chunks = [];
res.on("data", (c) => chunks.push(c));
res.on("end", () => {
const body = Buffer.concat(chunks).toString("utf-8");
console.log(res.statusCode, body);
});
});
req.on("error", (err) => console.error(err));
req.end();The generated snippet imports node:https.
Fix: Swap to node:http if the URL is plain HTTP.
Large binary bodies are inlined.
Fix: For large uploads, switch to fs.createReadStream().
-X / --request, -H / --header, -d / --data*, -u / --user, --url.
No — it relies only on node:https and node:url.
It defaults to https; swap imports manually for http URLs.
No — it only generates code.
No — parsing runs in your browser.
Pair with the curl-to-fetch converter and JSON / JWT helpers. You can also browse the full Generators category for more options.
Convert any curl command into modern JavaScript using the browser fetch API with await / async
Format, validate, and beautify JSON online with readable indentation, syntax checking, and copy-ready output for APIs, logs, and config files.
Decode and view JWT token payloads
Encode or decode Base64 strings
Parse a URL into scheme, host, port, path, query parameters, fragment, and origin — fully client-side
Search and learn about HTTP status codes. Find meaning, common causes, and fix solutions for any HTTP response code.
Convert curl commands to PHP code
Compose and export Apple App Store screenshot sets
Searchable ISO 3166 country list with two-letter codes and localised names
Generate cron schedule expressions visually
Generate sample CSV data
Generate date format strings and code snippets for JavaScript, Python, and C#