Paste any cURL command and instantly get idiomatic HTTP client code in your favorite language. Handles methods, headers, JSON/form data, Basic Auth, cookies, file uploads and more. 100% client‑side – your command never leaves your browser.
cURL is the swiss‑army knife for testing APIs, but embedding raw curl commands into applications is impractical. Manually rewriting requests in Python, JavaScript, or other languages is error‑prone – you might miss headers, misinterpret data formatting, or mishandle authentication. This converter bridges the gap: it parses your curl command exactly as curl itself does and generates idiomatic, production‑ready code for multiple languages. Over 50,000 developers use it weekly to accelerate API integration.
⚙️ Supported curl options: -X, --request · -H, --header · -d, --data, --data-raw · --data-binary · -F, --form · -u, --user · -b, --cookie · -A, --user-agent · URL parameters, and more.
The converter implements a full curl command parser written in JavaScript, following the grammar described in the official curl man page and verified against the curl source code (test suite). It tokenizes the command, respects quoted arguments (single, double, and backtick), handles escaped characters, and builds a structured representation containing the HTTP method, URL, headers, data payload, multipart fields, and authentication.
For each target language, we apply a template‑based code generator that emits best‑practice snippets. For example:
requests library. If Content-Type: application/json is detected, we use the json= parameter for automatic serialization. Form data uses data=.
fetch (or optionally axios – coming soon). Handles JSON stringification and URLSearchParams for forms.
curl_setopt sequence compatible with most PHP versions.
net/http package.
System.Net.Http.HttpClient with async pattern.
* Additional languages added regularly based on user requests. You can vote for the next language on our feedback page.
| cURL snippet | Python (requests) | JavaScript (fetch) |
|---|---|---|
-X PATCH -d '{"op":"replace"}'
|
requests.patch(url, json={"op":"replace"})
|
method: 'PATCH', body: JSON.stringify({"op":"replace"})
|
-H "X-API-Key: 123" -H "Accept: application/json"
|
headers={'X-API-Key':'123','Accept':'application/json'}
|
headers: {'X-API-Key':'123','Accept':'application/json'}
|
-d "name=John&age=30" (form)
|
data={'name':'John','age':'30'}
|
body: new URLSearchParams("name=John&age=30")
|
-u admin:secret (Basic Auth)
|
auth=('admin','secret')
|
headers: {'Authorization': 'Basic ' + btoa('admin:secret')}
|
-b "sessionid=abc123" (Cookie)
|
cookies={'sessionid':'abc123'}
|
headers: {'Cookie':'sessionid=abc123'}
|
-F "file=@/path/to/image.png"
|
files={'file': open('/path/to/image.png','rb')}
|
FormData append('file', fileInput.files[0]) (browser) / form-data library (Node)
|
Stripe’s official documentation often shows curl commands like:
curl https://api.stripe.com/v1/charges \ -u sk_test_4eC39HqLyjWDarjtT1zdp7dc: \ -d amount=2000 \ -d currency=usd \ -d source=tok_visa
With our converter, you get Python code instantly:
import requests
response = requests.post('https://api.stripe.com/v1/charges',
auth=('sk_test_4eC39HqLyjWDarjtT1zdp7dc', ''),
data={'amount': '2000', 'currency': 'usd', 'source': 'tok_visa'})
This eliminates manual concatenation and ensures the data is form‑encoded correctly, just as curl does.
Never commit hard‑coded credentials. The generated code may contain tokens, API keys, or passwords. Always replace them with environment variables or secure secrets management (e.g., os.getenv('API_KEY') in Python, process.env.API_KEY in Node). Our tool helps you see the structure, but you must secure the sensitive parts.
This tool is maintained by the GetZenQuery Tech team, with contributions from API enthusiasts worldwide. We follow these principles to ensure accuracy and trust:
“I use this converter almost daily when working with unfamiliar APIs. It saves me from having to mentally translate curl flags into Python requests syntax, especially with complex authentication headers. The code it generates is clean and ready to drop into my projects.”
--data-binary: The converter will preserve raw data as a string; you may need to adjust for file reading in your code.
-F): For Node.js, we currently generate a placeholder; you must use the form-data package. For Python, we emit the files parameter.
--compressed tells curl to handle gzip/deflate automatically. In generated code, most HTTP clients (requests, fetch) handle decompression automatically, so we omit it. --insecure disables SSL verification – we flag this with a comment in the generated code, as disabling verification is dangerous in production.
-b "name=value" into a Cookie header. For cookie jars (-c), we cannot fully replicate without a stateful client, but we add a comment indicating that you may need a session object.