Curl to Code: Convert Any curl Command to Python, JavaScript or Node
Convert curl commands to fetch, Axios, Node https or Python requests code free online — headers, body and auth mapped correctly. No sign-up, nothing uploaded.
Try it now: cURL to JavaScript Fetch Converter — Paste a cURL command and get clean fetch() code with headers, body, auth and method preserved. Nothing is sent to a server.
What a curl to Code Converter Actually Has to Parse
A curl command pasted out of an API's docs, a colleague's terminal, or DevTools' Copy as cURL is a full HTTP request encoded as command-line flags. A curl to code converter online has one job: read those flags correctly and produce the equivalent request in a target language, rather than a rough approximation that happens to run. That means parsing five things reliably, not just splitting the string on spaces:
-H,--header— one header per flag. Repeat the same header name and the last value wins; a converter that silently keeps only the first occurrence gets it backwards.-d,--data,--data-raw— the request body. Whether it becomes a JSON payload or a form-encoded string depends on theContent-Typeheader sitting alongside it, not on the flag name itself.-X— an explicit HTTP method. Present or absent, it changes what a correct converter has to do next (see below).-u,--user— Basic Auth credentials, converted into anAuthorization: Basicheader built from a base64-encodeduser:passpair, not left as plain text for the target language to figure out.-F,--form— one multipart form field per flag, and the converter needs to tell a plain text field (-F "role=admin") apart from a file field (-F "[email protected]") by the leading@alone.
Get any one of those wrong and the converted code compiles or runs without complaint — it just sends a different request than the curl command did, which is a worse failure mode than a syntax error because nothing flags it.
The Gotcha: -d Implies POST, Even Without -X
This is the one detail worth being exact about. curl defaults to GET — unless a -d, --data, or --data-raw flag is present, in which case curl silently switches the method to POST, with no -X flag required at all. A naive converter that only checks for an explicit -X POST before deciding the method will read a command like curl https://api.example.com/users -d '{"name":"Ada"}' — no -X anywhere — and generate a GET request with a body silently attached or dropped, which is not what curl actually sent.
A second, more mundane thing to handle gracefully: a command copied straight out of Chrome or Firefox DevTools' Copy as cURL action rarely looks like a hand-typed one. It usually carries a --compressed flag (tells curl to request and transparently decompress gzip/br), a full set of browser-sent headers like sec-ch-ua and sec-fetch-mode, and shell-escaped quoting around the body that varies depending on whether DevTools exported the bash or the cmd variant. None of that should make a curl converter choke — --compressed and the browser-fingerprint headers can be parsed and either kept or safely ignored, and quoting differences are a parsing detail, not a reason to reject the input outright.
Four Targets, One curl Command
GenKitLab runs the same parsing logic across four output languages, because the right one depends entirely on where the converted code has to run, not on which is objectively “best”:
- fetch()— browser-native, no dependency to install. The right default for frontend code, a Cloudflare Worker, or a snippet meant to be pasted straight into DevTools' console.
- Axios — a config-object style that most existing Node and frontend codebases already depend on. Reach for it when the project already imports
axioselsewhere, rather than introducing a second way of making requests. - Node's built-in
httpsmodule— zero dependencies, at the cost of more boilerplate than fetch or Axios. The right pick for a script or a Lambda where adding a package isn't worth it for one request. - Python
requests— for backend code and scripting outside the JS ecosystem entirely. It has its own deep-dive, covering headers, JSON and multipart bodies, and auth mapping in full, in the curl to Python guide.
The same authenticated POST — the kind that shows up constantly when converting curl to fetch or converting curl to axios for a codebase that already has both around — makes the difference concrete:
curl -X POST https://api.example.com/users \
-H "Authorization: Bearer abc123" \
-H "Content-Type: application/json" \
-d '{"name": "Ada Lovelace", "role": "engineer"}'fetch("https://api.example.com/users", {
method: "POST",
headers: {
"Authorization": "Bearer abc123",
"Content-Type": "application/json",
},
body: JSON.stringify({ name: "Ada Lovelace", role: "engineer" }),
})
.then((res) => res.json())
.then((data) => console.log(data));axios({
method: "post",
url: "https://api.example.com/users",
headers: {
Authorization: "Bearer abc123",
"Content-Type": "application/json",
},
data: { name: "Ada Lovelace", role: "engineer" },
})
.then((res) => console.log(res.data));Same headers, same body, same method — the only real difference is fetch requiring a manual JSON.stringify() call and a .json() parse on the response, where Axios does both automatically. Neither is wrong; picking between them is a codebase decision, not a correctness one.
Convert curl to fetch, Client-Side, on GenKitLab
GenKitLab's cURL to Fetch Converter handles all of the above in one pass — paste a cURL command and get clean fetch() code back, with headers, body, auth, and method preserved exactly, including the implicit-POST case above. Every bit of parsing runs in your browser; nothing you paste is sent to a server, which matters more than it sounds when the command includes a live bearer token or session cookie copied straight out of DevTools.
The same logic to convert curl command to code for the other three targets lives at cURL to Axios and cURL to Node.js. For the deepest coverage of headers, JSON and multipart bodies, and auth mapping — worked through in full with a flag-by-flag reference table — the curl to Python guide is the one to read next; the mechanics it covers (what -F, -u, and -b actually mean) apply to every target language here, not just Python.
Frequently asked questions
›What is a curl to code converter?
A tool that parses a curl command's flags — headers, body, method, auth, form fields — and generates equivalent code in a target language: fetch(), Axios, Node's https module, or Python requests. A correct one parses the command properly rather than pattern-matching on individual flags in isolation.
›Does -d always mean POST in curl?
By default, yes. curl sends GET unless a -d, --data, or --data-raw flag is present, in which case it switches to POST automatically — no -X flag required. A converter that only checks for an explicit -X POST before choosing the method will misread a command that relies on this default, generating a GET request instead of the POST curl actually sent.
›Can I paste a command copied from Chrome or Firefox DevTools?
Yes. DevTools' Copy as cURL commonly adds a --compressed flag and a full set of browser-fingerprint headers (sec-ch-ua, sec-fetch-mode, and similar), plus shell-escaped quoting that differs between the bash and cmd export variants. A converter should parse all of that gracefully rather than reject the input because of the extra flags.
›curl to fetch or curl to axios — which should I use?
fetch() if the code runs in a browser or an edge runtime and you want zero dependencies. Axios if the codebase already imports axios elsewhere — it's not worth introducing a second HTTP client for one converted request. Node's built-in https module is the right pick specifically to avoid adding any dependency at all, at the cost of more boilerplate.
›Is it safe to paste a curl command with an Authorization header into an online converter?
It's safe with a tool that runs entirely client-side, like GenKitLab's — the parsing and code generation both happen in your browser, and the pasted command, including any bearer token or cookie in a -H flag, is never sent anywhere. That's worth checking before pasting a command into any converter, since a curl command copied from DevTools frequently does contain live credentials.
›Does converting curl to fetch or Axios handle multipart file uploads (-F)?
Yes — each -F flag becomes one field. A plain value (-F "role=admin") is written as a form field; a file field (-F "[email protected]", marked by the leading @) needs to be built as a File or Blob in fetch/Axios rather than a plain string, since the browser environment has no direct filesystem path equivalent to curl's @filename syntax.
Last updated