cURL to Python Converter
Paste a curl command and get Python code using requests, httpx or the standard-library urllib, with headers, JSON or form data, auth, files and timeouts.
Runs in your browser. Nothing you add is uploaded.
What the cURL to Python Converter does
Converting a curl command to Python is mostly bookkeeping: headers become a dictionary, -d becomes json= or data=, -u becomes an auth tuple, -F becomes files=, -m becomes a timeout. This converter does it for you in three flavours. requests is the everyday choice, httpx adds async and HTTP/2, and urllib ships with Python for when nothing else can be installed. It also explains the differences that catch people out, such as requests following redirects by default.
How to convert curl to Python
- Paste the curl command.
- Pick the library: requests, httpx or urllib.
- Keep “Check for errors” on if you want response.raise_for_status() after the call.
- Turn on “Match curl's redirect behaviour” if you want redirects ignored as curl does without -L.
- Copy the code, install the package (pip install requests) if needed, and replace placeholders.
The cURL to Python Converter runs entirely in your browser — nothing you enter is uploaded, stored, or logged.
When to use it
Scripting an API from its docs
Paste the curl example from a provider and get a runnable Python script for cron jobs, data pipelines and notebooks.
Replaying a browser request
Use Copy as cURL in DevTools, convert it and reproduce the call from Python to scrape or test an endpoint you are allowed to use.
Moving off a fragile shell script
Replace a bash script that builds curl commands with Python that can parse JSON and handle errors.
Good to know
- requests has no default timeout, so a stuck connection can hang forever. Always pass timeout=.
- Use json= instead of data= for JSON bodies: it serialises the dict and sets Content-Type.
- requests follows redirects by default for GET but not for HEAD.
- httpx times out after five seconds unless you set timeout.
- For many requests, create a Session (requests) or Client (httpx) so connections are reused.
Guides that use this tool
Frequently asked questions
Which library should I choose?
Why does the code send my JSON with json= instead of data=?
Does the converter run my request?
How do I send a file upload from Python?
What does verify=False do?
Why does the urllib output raise an exception on a 404?
Related tools
cURL to JavaScript Converter
Convert curl to fetch, XMLHttpRequest, Node.js https or jQuery.
HTTP Status Code Lookup
Look up any HTTP status code: meaning, causes and how to fix it.
HTTP Header Analyzer
Paste HTTP headers to see what each means and what to fix.
HTTP Header Generator
Generate security, CORS, cache and CSP headers for your server.