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.
Input
Code
Paste a curl command to convert it.
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 this page loads no advertising or analytics scripts and allows no outside network requests.
FAQ
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.
Source
- curl documentation, command-line options: curl.se/docs/manpage.html.
- Fetch Standard: fetch.spec.whatwg.org.