About the cURL to Python Requests
API documentation and browser developer tools give you curl commands; your script needs Python. Paste a curl command and get clean code for the requests library: the URL, a headers dictionary, a JSON body turned into a real Python dictionary (with True, False and None), form data, and Basic auth as an auth tuple.
The method is taken from -X or inferred from the body, and unusual methods use requests.request. Tokens in the command never leave your browser. Supported flags are -X, -H, -d and the other --data variants, --json, -u, -A, -b, -e and -I.
How to use the cURL to Python Requests
- Paste a curl command.
- Review the generated Python.
- Copy or download the .py file.
Features
- JSON bodies as Python dicts
- Headers, cookies and auth
- Any HTTP method
- Local conversion
Supported formats
- Plain text
Frequently asked questions
Why is Content-Type missing from headers?
With json=…, requests sets Content-Type: application/json automatically.
Is my text sent anywhere?
No. Everything runs in your browser, so nothing you paste is uploaded or stored.