cURL to Python
Paste a curl command and get Python code using requests — or pick any other language.
Paste a curl command above to generate code
How curl maps to Python (requests)
- →-H headers become the headers dict; -d / --data becomes data=, sent as-is like curl does.
- →-u user:password becomes an Authorization: Basic header; requests can also take auth=(user, password).
- →If the body is JSON, you can swap data= for json= with a dict — requests then sets Content-Type for you.
- →Prefer async code? Pick Python (httpx) — same shape, and httpx.AsyncClient works with await.
Frequently asked
How do I convert a curl command to Python requests?
Paste the command above and pick Python (requests). Each -H becomes an entry in the headers dict, -d becomes the data argument, and -X sets the method passed to requests.request().
Why does my converted request get a 415 or 400 error?
The API usually expects JSON. Keep the Content-Type: application/json header from the curl command, or pass the body with json= instead of data=.