FREE TOOL

curl to Python Converter

Paste a curl command, get working Python requests code — headers, cookies, JSON and form bodies, auth, proxies, and file uploads translated. Runs in your browser, no signup.

Conversion runs entirely in your browser — the command (and any tokens or cookies in it) is never sent to a server. Tip: DevTools Network tab → right-click a request → Copy as cURL.

Scraping a real site? Skip the blocks

Hand-copied curl headers go stale, and sites still block datacenter IPs. The same request through the WebScraping.AI API gets rotating proxies, headless Chrome rendering, and unblocking in one call — your custom headers and cookies are forwarded via the headers parameter:

2,000 free API credits · No credit card required

What the generated requests code does

The converter produces idiomatic requests calls, not a literal flag-by-flag translation: -H headers become a headers dict and -b cookies a cookies dict; a JSON body is passed as json= (a Python dict, so requests sets the Content-Type and serialization for you) while form data uses data=; -u maps to auth=(user, pass), -F file uploads to files= with opened file handles, -x to a proxies dict, -m to timeout=, and -k to verify=False.

Two curl-to-requests differences worth knowing: requests follows redirects by default, so -L needs no translation — and it sends User-Agent: python-requests/… by default, which many sites block on sight. That's why the converter keeps every header from your original command.

Frequently asked questions

How do I convert a curl command to Python?

Paste the command into the converter above — it outputs Python requests code instantly, in your browser. Headers, cookies, JSON or form bodies, basic auth, proxies, timeouts, and file uploads are all translated. Nothing you paste is sent to a server.

Why use requests instead of urllib or httpx?

requests is the de-facto standard for synchronous HTTP in Python and what most scraping tutorials and libraries assume. urllib is standard-library but verbose; httpx has a nearly identical API to requests, so the generated code ports over with little more than an import change if you need async.

Why does the converter use json= for some bodies and data= for others?

If the curl command sends a JSON body (via --json or a Content-Type: application/json header), the converter emits it as a Python dict passed to json=, which is the idiomatic form. Form-encoded bodies become a dict passed to data=, and anything else is kept as a raw string.

The Python code gets a 403 but the same curl command works — why?

Sites can distinguish clients by TLS fingerprint and IP reputation, not just headers, and python-requests has a well-known fingerprint. Copying browser headers helps briefly; the durable fix is routing requests through rotating proxies and a real browser — which is what the WebScraping.AI API does in one call.

Related

Python code ready? Make it unblockable.

Same request, plus rotating proxies, headless Chrome, and JS rendering — one API call from Python.

Icon