pythonrequests.com

cURL to Python requests

Paste a cURL command, get a runnable requests.request() call. Parsed locally, nothing is uploaded.

 

How the conversion works

The input is tokenized the way a POSIX shell would read it: single quotes, double quotes, $'…' strings and backslash line continuations are resolved before any flag is interpreted. Each flag is then mapped onto the equivalent argument of requests.request().

A body that parses as JSON is emitted as a Python dict passed to json=, so requests sets the Content-Type header and serializes it for you. Any other body is passed verbatim to data=.

cURL flag mapping

cURL flagPython requestsNotes
-X, --request method argument Defaults to POST when a body is present, otherwise GET.
-H, --header headers={…} Content-Type is dropped when json= is used.
-d, --data-raw json= or data= JSON is detected from content, not only from the header.
-u, --user auth=(user, pass) Sent as HTTP Basic.
-b, --cookie Cookie header Passed through unchanged.
-k, --insecure verify=False Disables TLS verification. Avoid outside testing.

FAQ

How do I convert a cURL command to Python requests?

Paste the command into the left pane. The converter maps -X to the HTTP method, each -H to a headers dict entry, and -d to json= (when the body is valid JSON) or data= otherwise.

Can I copy a cURL command from Chrome DevTools?

Yes. In the Network tab, right-click a request and choose Copy > Copy as cURL. Both bash and cmd variants are accepted.

Is my request sent to a server?

No. Conversion runs in your browser. Authorization headers and tokens in the pasted command never leave the page.