cURL to code fetch, axios, Python, Go and PHP from any curl command.
fetch, axios, Python, Go and PHP from any curl command.{
"email": "ada@example.com",
"name": "Ada Lovelace",
"metadata": {
"plan": "pro",
"seats": 3
}
}const res = await fetch("https://api.example.com/v1/customers", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.API_TOKEN}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "ada@example.com",
name: "Ada Lovelace",
metadata: {
plan: "pro",
seats: 3,
},
}),
});
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const data = await res.json();Copy any request as cURL
Then paste it above.
- Chrome · EdgeDevTools → Network. Right-click the request → Copy → Copy as cURL (bash).
- FirefoxNetwork tab. Right-click the request → Copy Value → Copy as cURL.
- SafariWeb Inspector → Network. Right-click the request → Copy as cURL.
- Postman · Insomnia · docsOpen the code view and pick cURL. Most API docs show a cURL example too.
Questions
The short answers.
Is my token sent anywhere?
No. The command is parsed and the code written in this tab. With “Secrets as env variables” on, tokens and passwords don't even appear in the code you copy.
What are “browser headers”?
Headers like sec-ch-ua, sec-fetch-*, user-agent and accept-language that browsers add on their own. APIs almost never need them, so leaving them out keeps your code readable.
Why isn't -k in the code?
-k turns off certificate checks. It's handy for a quick local test but dangerous in code that ships, so we flag it instead of copying it.
Does it handle Windows commands?
Yes — line breaks with \ (bash), ^ (cmd) and ` (PowerShell) all work, as do single, double and $'…' quotes.
Which curl options are understood?
Method, headers, -d, --data-raw, --data-binary, --data-urlencode, --json, -F forms and file uploads, -u, -b cookies, -G, -L, -k, -m and --url-query. Options with no equivalent in code, like --retry or --cacert, are read and listed as ignored, so their values are never mistaken for the URL.