Developer Tools
curl to fetch, Python and axios.
Paste a curl command, for example one copied from your browser's dev tools or an API doc, and get equivalent JavaScript or Python code. Headers, JSON bodies, basic auth and form fields are carried over. The command is never sent anywhere.
How to convert a curl command to code
- Paste a curl command, for example one copied from your browser's developer tools with Copy as cURL, or from API documentation.
- Choose the target: JavaScript fetch, JavaScript axios or Python requests.
- Copy the generated code into your script.
Check before you run it
The converter carries over the method, URL, headers, JSON bodies, form fields, basic authentication, cookies and the user agent, but it cannot run the request or know what a server will do. Read the generated code and run it against a test endpoint first. Commands copied from a browser often include dozens of headers, cookies and tracking values you do not need, so strip them down to the ones the API actually requires.
Treat any command from a browser as secret. It may contain session cookies, bearer tokens and API keys that grant access to your account, and pasting them into a script that you share or commit can leak them. Replace credentials with environment variables in the code you keep.
Your command never leaves this page
The converter runs in your browser, inside an isolated frame on this page that has no network access. Your file is read and written back by your own device, so it is not uploaded to TNAADO or anyone else, and nothing is stored. The advertising on this page sits outside the frame and cannot see what you choose. Commands often contain tokens, so the conversion happens entirely in the frame and nothing is sent to a server.
- Unusual curl options may be ignored; compare the output with the original.
- Multi-step shell syntax such as pipes and variables is not evaluated.
About this curl converter
API documentation and browser dev tools ("Copy as cURL") give requests as curl commands. This tool turns one into code you can paste into a script: JavaScript fetch, axios, or Python requests.
What is carried over
- Method:
-X/--request, or inferred: POST when there is a body or form, otherwise GET.-Iis HEAD. - Headers: every
-H, plus-A(User-Agent),-e(Referer) and-b(Cookie). - Body:
-d,--data-raw,--data-binary,--jsonand--data-urlencode. Several-dflags are joined with&as curl does. With-Gthe data moves into the query string. Python output usesjson=when the body is JSON and the content type says so. - Auth:
-u user:passbecomes a BasicAuthorizationheader (fetch), anauthoption (axios) orauth=(...)(Python). - Forms:
-Ffields becomeFormDataor adata/filesdictionary;@filevalues need you to supply the file. - Flags:
-Lfollows redirects (otherwise redirects are switched off to match curl's default), and-kbecomesverify=Falsein Python.
What is not converted
Options with no direct equivalent, such as proxies, timeouts, cookie jars, client certificates and output files, are listed as warnings instead of being silently dropped. Output is meant as a starting point: review it before running it, especially anything involving credentials.
Privacy
curl commands often contain API keys and tokens. Conversion happens in your browser, and the isolated tool frame loads no advertising or analytics scripts and allows no outside network requests.
Source
- curl documentation, command-line options: curl.se/docs/manpage.html.
- Fetch Standard: fetch.spec.whatwg.org.
Worked example
Input command, converted by running this page’s converter code on 2026-10-26:
curl -X POST https://api.example.com/v1/items -H 'Content-Type: application/json' -H 'Authorization: Bearer TOKEN' -d '{"name":"widget","qty":3}'It is read as POST https://api.example.com/v1/items with a JSON body. The fetch output:
fetch("https://api.example.com/v1/items", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": "Bearer TOKEN"
},
body: "{\"name\":\"widget\",\"qty\":3}",
redirect: "manual"
})
.then((res) => res.text())
.then(console.log);The python output:
import requests
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer TOKEN',
}
json_data = {
'name': 'widget',
'qty': 3,
}
response = requests.request('POST', 'https://api.example.com/v1/items', headers=headers, json=json_data, allow_redirects=False)
print(response.text)Sources and as-of date
As of 2026-10-26. The option meanings come from the curl manual and the generated fetch call follows the Fetch Standard. Replace TOKEN and similar placeholders before you run any generated code.
- curl manual page (retrieved 2026-10-26): what each command-line option means.
- WHATWG Fetch Standard (retrieved 2026-10-26): the request and header model that fetch() follows.
Frequently asked questions
How do I convert a curl command to Python?
Paste the command, choose Python (requests) and copy the code. JSON bodies use the json= argument so requests sets the right encoding.
How do I get a curl command from my browser?
Open dev tools, go to the Network tab, right-click a request and choose Copy as cURL. Paste it here. Remove cookies and tokens before sharing the result.
Is my curl command sent to a server?
No. It is parsed in your browser and this page blocks outside network connections.