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 →

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.