Convert curl to Python

Paste your curl command below — the Python · requests code is generated instantly, entirely in your browser.

// your code will appear here

How the curl to Python conversion works

Every curl flag maps to part of a requests call: -H flags become entries in the headers dict, -d becomes data (or json when the body is JSON), -u becomes the auth= tuple, and -b becomes a Cookie header. Paste your command above and the Python code updates as you type.

Common conversions

A JSON POST with curl:

curl -X POST https://api.example.com/users \
  -H 'Content-Type: application/json' \
  -d '{"name": "Alice"}'

becomes:

import requests

url = 'https://api.example.com/users'
json_payload = {
    'name': 'Alice',
}
headers = {
    'Content-Type': 'application/json',
}
response = requests.post(url, headers=headers, json=json_payload)

FAQ

Does it support --json?

Yes — the curl 7.82+ --json shorthand is detected and converted to json=.

Is my data sent anywhere?

No. Parsing and generation happen entirely in your browser.