cURL to Python (requests)
Parse a curl command (from the browser "Copy as cURL") and generate an equivalent runnable Python script using requests or httpx — method, headers, JSON/form bodies, cookies, basic auth and TLS options included.
Paste your curl command
How it works
- Tokenizes the command, respecting single and double quotes with escapes.
- Maps
-X,-H,-d/--data-raw/--json,-u,-b,-A,-F,-L,--compressedand--insecureto requests/httpx arguments. - JSON payloads become
json=dicts, form payloads becomedata=dicts, anything else is passed as a raw string. - Unsupported flags are listed as comments in the output instead of being silently dropped.
About cURL to Python
When you copy a request out of the browser network tab or a README, curl is the format you get — but a Python script, test or automation job wants requests or httpx instead. This converter reproduces the request semantics: repeated headers are merged into a dict, JSON-looking bodies become json= so they are serialized correctly, cookies become a cookies= dict, and basic auth becomes auth=(user, password).
The generated script is complete and runnable: imports, a try/except around the call, a printed status code and response text. Options that have no Python equivalent — like -o file output or exotic curl flags — are kept as comments so you know what was skipped. Defaults differ in one notable way: curl sends Content-Type: application/x-www-form-urlencoded for -d payloads, while requests does not; the converter preserves the headers you actually passed.