cURL to Python Requests Converter
Convert any curl command into working Python requests code. Handles headers, JSON and form bodies, basic auth, cookies, query parameters and file uploads.
What is the cURL to Python Requests Converter?
Paste a curl command and get back readable Python that uses the requests library. A quote-aware tokeniser splits the command the way a shell would, including backslash line continuations, so commands copied out of a terminal or a browser's Copy as cURL work unchanged.
- Shell-accurate tokeniser handling quotes, escapes and multi-line commands
- JSON bodies detected and emitted as a Python dict passed to json=
- Query string split into a params dict instead of being buried in the URL
- Maps -u to auth, -b to cookies, -F to files, -k to verify=False and -L to allow_redirects
- Unsupported flags surfaced as explicit notes rather than silently ignored
- Runs entirely in your browser — no request is ever sent
How to use the cURL to Python Requests Converter
- 1
Paste your curl command, including any backslash line continuations.
- 2
Click Convert to Python.
- 3
Read any notes about flags that could not be translated directly, such as proxies or file references.
- 4
Copy the generated code or download it as request.py.
- 5
Install requests with pip install requests and run the script.
About the cURL to Python Requests Converter
Paste a curl command and get back readable Python that uses the requests library. A quote-aware tokeniser splits the command the way a shell would, including backslash line continuations, so commands copied out of a terminal or a browser's Copy as cURL work unchanged.
Headers become a headers dict, -d bodies become data= or json= depending on whether the payload parses as JSON, -F becomes files= and form fields, -u becomes an auth tuple, cookies become a cookies dict, and the query string is split out into params= so the request is easy to edit later.
Flags that requests handles differently — or not at all — are reported as notes rather than dropped silently. Nothing is executed and no request is made: the command is parsed locally in your browser and only text is produced.
Frequently asked questions
How do I convert a curl command to Python?
Paste the command and click Convert. Each flag maps onto a requests argument — -H to headers, -d to data or json, -u to auth — and the result is a short script you can run with Python once requests is installed.
When does the tool use json= instead of data=?
When the body parses as valid JSON, or the Content-Type header says JSON. Using json= lets requests serialise the dict and set the header for you, which is usually what you want; a body that is not valid JSON is passed through as a raw string with data=.
How do I get a curl command from my browser?
Open DevTools, go to the Network tab, right-click the request and choose Copy as cURL. Paste that straight in here. Remember it will include your real session cookies and auth headers, so treat the result as a secret.
What does verify=False do?
It is the translation of curl's -k flag and disables TLS certificate verification. It is fine for a local server with a self-signed certificate, but it removes protection against interception, so never leave it in production code.
Why is my file upload not fully converted?
curl's -F with an @path reference points at a file on disk. The generated code opens that path with open(path, "rb"), but you will need to make sure the path is correct relative to where you run the script.
Is the request actually sent?
No. The command is only parsed into text. Nothing is executed and nothing is uploaded, so it is safe to paste commands containing API keys or session tokens.
Related tools
Postman Collection to cURL Converter
Convert an exported Postman collection into curl commands. Walks nested folders, substitutes {{variables}} and handles raw, form-data and urlencoded bodies.
docker run to docker-compose Converter
Convert any docker run command into a docker-compose.yml file. Maps ports, volumes, environment, networks, restart policies and healthchecks to Compose YAML.
OpenAPI to Markdown Converter
Convert an OpenAPI 3.x or Swagger 2.0 JSON spec into readable Markdown API documentation with parameter, request body and response tables.
JWT Decoder
Decode JWT header and payload instantly, with human-readable iat/exp/nbf timestamps and an expiry badge. Client-side only — tokens never leave your browser.