cURL to Python
Paste a cURL command and get equivalent Python code using the requests library. JSON bodies become json= payloads when they parse, other bodies use data=, and basic auth becomes an Authorization header, ready to paste into a script.
cURL command
Python requests
Result will appear hereReady. Press Convert or Ctrl+Enter.
How to use the cURL to Python
- Paste a full cURL command.
- Press Convert.
- Copy the Python code (requires the requests package).
Example
The Authorization header is preserved in the headers dict.
curl https://api.example.com/me -H "Authorization: Bearer TOKEN"
Frequently asked questions
Does the output need requests installed?
Yes, pip install requests. The converter targets requests because it maps closely to cURL; urllib output is not offered.
Are secrets in my command safe?
Conversion happens in your browser, but treat pasted tokens with the same care as anywhere else. Nothing is uploaded.