Convert cURL to Python
Transform cURL commands into production-ready Python code instantly. Our converter supports both the popular Requests library and Python’s built-in HTTP client.
Quick Example
Convert this cURL command:
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"name":"John Doe","email":"[email protected]"}'
Into Python (Requests):
import requests
url = "https://api.example.com/users"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN"
}
data = {
"name": "John Doe",
"email": "[email protected]"
}
response = requests.post(url, headers=headers, json=data)
Why Use Python Requests?
- ✅ Simple & Pythonic - Clean, readable syntax
- ✅ Battle-tested - 50M+ downloads/month
- ✅ Feature-rich - Sessions, cookies, auth built-in
- ✅ JSON support - Automatic encoding/decoding
Common Use Cases
GET Request with Query Parameters
curl "https://api.example.com/search?q=python&limit=10"
Converts to:
import requests
url = "https://api.example.com/search"
params = {
"q": "python",
"limit": "10"
}
response = requests.get(url, params=params)
File Upload
curl -X POST https://api.example.com/upload \
-F "[email protected]" \
-F "category=reports"
Converts to:
import requests
url = "https://api.example.com/upload"
files = {
'file': open('document.pdf', 'rb')
}
data = {
'category': 'reports'
}
response = requests.post(url, files=files, data=data)
Try It Live
Open the converter to transform your cURL commands, or use RequestBin’s advanced converter to test the generated code with real HTTP endpoints.
Related docs: JavaScript | Node.js | How It Works