curl to code
Parse a curl command into a structured request and generate fetch, axios, Python requests, Go net/http, PHP cURL, Java HttpClient and C# HttpClient code, with warnings for unsupported options.
Runs in your browserEvery computation happens in your browser — your data never leaves this device.
Parsed request
POSThttps://api.example.com/usersJSON2Generated code
const response = await fetch("https://api.example.com/users", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: "{\"name\":\"Ada\",\"role\":\"admin\"}",
});
const data = await response.json();
console.log(data);What this tool does
- Copy as cURL from your browser devtools and turn it into runnable fetch, axios, Python requests, Go, PHP, Java or C# code.
- When integrating a third-party API, verify the call with curl first and then convert it to the language your project uses, instead of hand-copying headers and bodies.
- Learn how different HTTP clients express the same request: seven languages side by side beats reading seven sets of docs.
- Debug "my code sends a different request than curl": first check that the parsed method, URL, body type and header count match what you expect.
Example
Input
curl -X POST https://api.example.com/users -H 'Content-Type: application/json' -H 'Accept: application/json' -d '{"name":"Ada","role":"admin"}'Output
const response = await fetch("https://api.example.com/users", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: "{\"name\":\"Ada\",\"role\":\"admin\"}",
});
const data = await response.json();
console.log(data);The body is recognised as JSON, so the response is read with response.json(); without a Content-Type header it is treated as raw text and response.text() is used.
Frequently asked questions
Which curl options are understood?
-X/--request, -H/--header, the -d/--data family, -F/--form, -u/--user (Basic auth), -b/--cookie, -G/--get, -L and -k. Unknown options are never dropped silently — they are listed under "options that could not be parsed" so you can judge the impact.
What about secrets in the generated code?
Headers such as Authorization are copied verbatim so the snippet runs immediately, which also means credentials end up in the code and in your clipboard history. Only paste real credentials in a trusted environment, and swap them for environment variables before committing.
Are -k and --compressed converted?
They have no equivalent. The tool says so explicitly: -k (skip TLS verification) needs extra configuration in most HTTP clients, and --compressed is negotiated by default in most of them, so neither appears in the output — add them by hand if you need them.
Why does the generated code have extra backslashes in the URL and body?
That is string escaping, not different content. A double quote in the original JSON must be written as \" inside a JS string literal; when the snippet runs it is exactly {"name":"Ada"}. Shell commands quoted with single quotes introduce no extra escaping.
Is the command uploaded anywhere?
No. Tokenising, parsing and code generation are all local string work, the page makes no network requests, and it works offline.
Keywords:curlcurl 转代码fetchaxiosrequestsnet/httpphp curlhttpclient命令转换code generator