toolqik

60 · API & Webhooks

cURL to Python Converter

Turn any curl command into Python code using requests or httpx.

Runs in your browser
Library
Python

  

About this tool

Paste a curl command from API docs or your browser and get the equivalent Python code. JSON bodies become Python dictionaries passed with json= (so true, false and null become True, False and None), form uploads use files= with open(…, "rb"), and -u user:pass becomes auth=(…).

Supported curl options

-X, -H, -d / --data / --data-raw / --data-binary / --data-urlencode, --json, -F (multipart), -u (Basic auth), -b (cookies), -A, -e, -G, -I, -L, -k and combined flags like -sSL. Bash quoting, $'…' strings and line continuations work, and so does Chrome DevTools’ “Copy as cURL (cmd)” output for Windows. Options without an equivalent, like -o or -v, are listed so nothing is silently lost.

Copy a request from the browser: open DevTools → Network, right-click a request → Copy → Copy as cURL, and paste it here.

requests or httpx?

  • requests is the classic, synchronous HTTP library: pip install requests.
  • httpx has nearly the same API, plus async support (httpx.AsyncClient) and HTTP/2: pip install httpx.

Differences from curl to know

  • Redirects: requests follows them by default, httpx doesn’t, and curl only does with -L. The code sets allow_redirects or follow_redirects so it behaves like your command.
  • Errors: neither library raises on 4xx and 5xx responses by itself; the generated response.raise_for_status() does.
  • Timeouts: requests waits forever by default. Add timeout=10 in production code (httpx defaults to 5 seconds).

FAQ

How do I convert curl to Python requests?

Paste the curl command above. The requests code appears instantly; choose httpx if you prefer it.

How do I send JSON with requests?

Pass a dict with json=…; requests serialises it and sets Content-Type: application/json. The converter does this for JSON bodies.

Why does my converted request follow a redirect?

requests follows redirects by default. The generated code adds allow_redirects=False unless your curl command used -L.

Does it handle file uploads?

Yes. -F "file=@photo.jpg" becomes files={"file": open("photo.jpg", "rb")}.

esc
↑↓ navigate↵ open