cURL Converter
Convert cURL commands to JavaScript fetch or Python requests code
About cURL Converter
Turns a cURL command (for example copied from your browser's "Copy as cURL") into JavaScript fetch code or Python requests code.
Paste the cURL command, pick the language and press Convert. Headers, method, JSON or form data, basic auth, cookies and the -k and -L switches are carried over. Switches that have no equivalent are listed under the code so nothing is dropped silently.
Copied commands often contain real tokens and cookies. Everything here runs in your browser and nothing is sent anywhere, but remove secrets from the generated code before you share or commit it.
- Where do I get a cURL command from?
- In the browser's developer tools open the Network tab, right-click a request and choose Copy as cURL. API documentation often shows ready cURL examples as well.
- Which cURL options are converted?
- The URL, method, headers, data and JSON bodies, form fields and file uploads, basic auth, user agent, referer, cookies, insecure mode and following redirects. Anything else is listed as not converted.
- Why does the code include my token or cookie?
- Because the command did. The converter copies what it is given. Remove or replace secrets such as tokens and cookies before sharing the code, and prefer environment variables.
- Does it make a request to the address?
- No. It only rewrites the command as code. Nothing is sent to the URL and nothing is uploaded.
- Does the fetch code work in Node as well as the browser?
- Yes for current Node versions, which include fetch. Basic auth uses btoa, which is also available there. The file upload example refers to a browser file input and needs adapting in Node.
How to use cURL Converter
Paste a cURL command into the box (browser developer tools offer 'Copy as cURL' on any network request), choose JavaScript (fetch) or Python (requests) and press Convert. The code appears below with a Copy button. Switch the language button to see the same request in the other language.
When to use it
Use it when API documentation or a browser request gives you a cURL command and you need the same call in code. It saves retyping headers and bodies and avoids quoting mistakes. It is also a quick way to learn how a request maps to fetch or requests.
When not to use it
It reads one cURL command and writes a starting point, not finished production code. Error handling, retries, timeouts, streaming and multi-step flows are not generated. Unusual switches are not translated and are listed so you can handle them yourself.
Tips for best results
If your JSON body is valid, the fetch output wraps it in JSON.stringify and the Python output uses json= with a native dictionary. For uploads, the generated fetch code expects a file input called fileInput and the Python code opens the file by the name in the command. Replace real tokens with environment variables.
Limitations
Supported: the URL, -X, -H, -d and --data variants, --data-urlencode, --json, -F form fields and file uploads, -u basic auth, -A, -e, -b cookies, -k, -L and the head request. Other switches such as --retry, proxies and certificates are listed under the code as not converted. Shell variables such as $TOKEN are not expanded.
Privacy
The command is parsed in your browser and nothing is sent anywhere. It may contain tokens or cookies, so check the generated code before sharing or committing it.
More from Security & Developer: