cURL to Python Requests
Paste any curl command and get ready-to-run Python code — requests, httpx, or urllib.
About cURL to Python Requests Converter
This tool converts any curl command into equivalent
Python code. It supports three popular output styles: the de-facto standard requests library, modern httpx (with optional async / await),
and the dependency-free urllib module from the Python standard library.
Everything runs 100% in your browser — your commands, tokens, and API keys never leave your device. Parsing handles multi-line commands with backslash continuation, single and double quotes, headers, JSON bodies, form fields, basic auth, cookies, user-agent, referer, TLS options, and more. JSON request bodies are decoded into proper Python dicts so the output is idiomatic and easy to edit.
How to Use
- Paste your curl command on the left (works with multi-line commands using
\continuations), or click Load Sample to try it out. - Pick your output style: requests, httpx, or
urllib. With httpx you can toggle async mode. - View the Python code on the right — it updates as you type or change options.
- Copy the result with the Copy button and paste it into your Python project.
Add your real credentials/tokens before running, and install the library with
pip install requestsorpip install httpxas needed.
Supported curl Flags
Request
-X / --request— HTTP method-H / --header— request headers-d / --data / --data-raw— body-F / --form— multipart form-G / --get— force GET-I / --head— HEAD request
Options
-u / --user— basic auth-A / --user-agent-e / --referer-b / --cookie-L / --location— follow redirects-k / --insecure— skip TLS verify--compressed
Common Use Cases
- API integration: Drop in a curl example from API docs (Stripe, OpenAI, GitHub, Twilio) and get working Python code instantly.
- Data scraping & ETL: Convert curl snippets from browser DevTools "Copy as cURL" into requests-based scrapers and pipelines.
- Automation scripts: Quickly turn curl commands from Stack Overflow or support tickets into Python automation glue.
- Async services: Generate
httpxasync code for FastAPI background tasks, asyncio jobs, or high-concurrency clients. - Learning Python HTTP: See how the same request maps to requests, httpx, and urllib side by side.
Frequently Asked Questions
Which Python output style should I pick?
Use requests for almost any project — it's the de-facto standard, has the largest ecosystem, and works for synchronous code. Pick httpx if you need HTTP/2, async/await, or a drop-in modern replacement (FastAPI, asyncio apps, Trio). Pick urllib only when you can't add dependencies — it's part of the Python standard library and ships everywhere.
Does this tool handle multi-line curl commands?
Yes. Backslash + newline continuations (\ at the
end of a line) are joined before parsing, so you can paste curl commands exactly as they
appear in documentation or in the output of "Copy as cURL" from browser DevTools.
Are JSON request bodies handled correctly?
Yes. When the -d body parses as valid JSON, the
output uses the json= keyword argument with a
proper Python dict / list literal — so requests/httpx will set the correct Content-Type and serialize it for you. Non-JSON bodies fall back to data=.
Is multipart form data (-F) supported?
Yes. -F key=value pairs are converted to a Python files= dict so requests/httpx send a proper multipart
request. For file uploads (-F file=@path), replace the
generated value with open("path", "rb") before running.
How is basic auth (-u user:pass) converted?
For requests and httpx, the credentials become an auth=(user, pass) tuple — both libraries handle
basic auth natively. For urllib, an Authorization: Basic header is added with the base64-encoded credentials.
Is my curl command sent to a server?
No. Parsing and code generation run entirely in your browser using JavaScript. Your curl commands — including any API tokens, bearer tokens, or cookies — never leave your device, so it's safe to use with production credentials.
What Python version is the output compatible with?
Generated code targets Python 3.7+. The requests output works with requests 2.x. The httpx output works
with httpx 0.24+ (sync or async). The urllib output
uses only standard library modules, so it runs on any modern Python install.
Should I use -k / --insecure in production?
No. -k disables TLS certificate verification
and exposes you to man-in-the-middle attacks. The converter honors the flag if present for
parity with your curl command, but remove verify=False (requests/httpx) or the custom SSL
context (urllib) before shipping the code to production.
Can I reuse a session across multiple requests?
The generated snippet is a single request. For session reuse — connection pooling, persistent
cookies, default headers — wrap the call in requests.Session() or httpx.Client() / httpx.AsyncClient() and call methods on the session
instead of the module.