Advertisement

cURL to Python Requests

Paste a cURL command and convert it into Python requests code. JSON bodies become json= dicts, headers become a dict, and auth becomes the auth tuple.

cURL to Python

Paste a cURL command below.

Advertisement

How the conversion works

The parser reads the method, URL, headers and body, then emits requests.get or requests.post with matching arguments. When the content type is JSON, the body is parsed and emitted as a Python dict via json=, with True, False and None translated correctly.

From docs to script

API documentation written for terminal users becomes a runnable Python script in one step. It is the fastest path to a quick data pull, a webhook test or a prototype integration.

cURL to Python FAQs

How are JSON bodies handled?
If the Content-Type is JSON, the body is parsed and emitted as a Python dict with the json= parameter. Otherwise it is passed as a raw string with data=.
How is basic auth handled?
The -u user:pass flag becomes the auth=(user, pass) tuple, which is the idiomatic requests way to do HTTP basic authentication.
What about the -k insecure flag?
It becomes verify=False in the output. Only use that for local testing, never in production, since it disables TLS certificate checks.
Does it handle file uploads?
Multipart -F uploads are not converted automatically. Use requests.post(url, files={...}) with the field names from the original command.
Is my command uploaded?
No. Parsing runs entirely in your browser, so URLs and credentials never leave your device.
Advertisement