cURL converter · Python
cURL to Python
Paste a curl command and get idiomatic Python. We pick json= over data= when Content-Type says JSON, emit auth=(user, pass) tuples for -u, and translate -F uploads into files={...}.
InputcURL command
1 secret
MethodPOST·Headers2·Body46 B· Chars 187
OutputPython · requests(sync)
import requests
headers = {
"Authorization": "Bearer sk_test_123",
"Content-Type": "application/json",
}
response = requests.post(
"https://api.example.com/v1/messages",
headers=headers,
json={
"to": "+15551234567",
"body": "Hello from curl"
},
)Inspect
Top guides for Python
All guides →POST in Python
/how-to/curl-post-in-python
GET in Python
/how-to/curl-get-in-python
JSON in Python
/how-to/send-json-with-curl-in-python
multipart form-data in Python
/how-to/send-multipart-with-curl-in-python
Bearer token in Python
/how-to/curl-bearer-auth-in-python
Basic auth in Python
/how-to/curl-basic-auth-in-python
Common questions
- Which library should I use?
- requests is the default for scripts. httpx if you also need async or HTTP/2. aiohttp if you're already inside asyncio and want session pooling.
- Does it handle JSON correctly?
- Yes. When Content-Type: application/json is set and the body parses, we emit json={...} so requests serializes and sets the header for you.
- What about basic auth and cookies?
- -u alice:s3cret becomes auth=('alice', 's3cret'); -b or --cookie is folded into the Cookie header.
- Is my curl sent anywhere?
- No. Parsing and code generation happen entirely in your browser.
Also convert cURL to
All guides →Same parser, same idiomatic output — swap the target language whenever your stack changes. Every hub carries its own reference guides for methods, payloads, and auth.