cURL to Python RequestsInstant local cURL conversion
en

AppHelp

Convert cURL commands to Python requests

Paste a cURL command and get readable Python immediately, with request details, secret warnings, examples, copy, and .py download.

cURL conversion workspace

Paste a command and review the Python requests code immediately.

Browser-local
Python requests output
POSThttps://api.example.com/users2 headers
import requests

headers = {
    "Content-Type": "application/json",
    "Accept": "application/json"
}

json_data = {
    "name": "Ada",
    "active": True
}

response = requests.request(
    "POST",
    "https://api.example.com/users",
    headers=headers,
    json=json_data,
    timeout=30,
    allow_redirects=False,
)
response.raise_for_status()
print(response.text)

Common tasks

  • curl to python requests
  • curl to python converter online
  • convert curl to requests
  • curl json to python
  • copy as curl to python
  • curl command converter
  • curl to requests session
  • curl multipart to python
  • browser local curl converter
  • free curl to python tool

Quick answer

Paste a cURL command to generate Python requests code in real time. The converter recognizes methods, headers, JSON and form bodies, Basic auth, cookies, multipart files, redirects, timeouts, and insecure TLS flags without sending the command to a server.

How to use

  1. 1. Paste or choose a cURL commandUse a command copied from browser DevTools or start with a built-in GET, JSON, auth, form, or upload example.
  2. 2. Review parsed request detailsCheck the detected method, URL, header count, warnings, and any sensitive-value alert before using the result.
  3. 3. Choose Python optionsSelect requests.request or requests.Session, set a timeout, and decide whether to raise HTTP errors, print the body, or mask secrets.
  4. 4. Copy, test, and adaptCopy or download the .py file, install requests, then test it in a safe environment and replace placeholder credentials.

Examples

JSON API request

Input
curl https://api.example.com/users --json '{"name":"Ada"}'
Output
requests.request("POST", url, headers=headers, json=json_data, timeout=30)

Valid JSON is emitted as a Python dictionary and passed with json= instead of a raw string.

Bearer token

Input
curl https://api.example.com/profile -H 'Authorization: Bearer TOKEN'
Output
headers = {"Authorization": "Bearer TOKEN"}

Enable secret masking before sharing the generated snippet.

Multipart upload

Input
curl https://api.example.com/avatar -F 'avatar=@photo.png'
Output
files = {"avatar": open("photo.png", "rb")}

Confirm that the local filename exists before running the script.

Common use cases

  • Turn API documentation examples into Python scripts
  • Reproduce a browser request captured with Copy as cURL
  • Create a starting point for integration tests and notebooks
  • Translate JSON, form, or multipart commands for debugging
  • Review headers and credentials before sharing a request

Edge cases

  • Shell substitutions, environment variables, and input files referenced with @ may require manual edits.
  • Proxy, client certificate, and uncommon transport flags are reported but not fully translated.
  • Requests and cURL have different redirect defaults, so the generated code sets allow_redirects explicitly.
  • Disabling TLS verification produces verify=False and should not be used casually.
  • A converted command can still contain live cookies or tokens; treat them like passwords.

Features

  • Instant cURL parsing and Python requests generation
  • JSON bodies become native Python dictionaries passed with json=
  • Form fields, multipart files, Basic auth, cookies, and headers
  • Request or Session output styles with timeout controls
  • Sensitive-header detection and optional secret masking
  • Copy or download a runnable Python file locally

Frequently asked questions

Does the converter send my cURL command anywhere?
No. Parsing and code generation happen locally in your browser.
Can it convert JSON request bodies?
Yes. Valid JSON bodies become Python dictionaries and use the requests json= argument.
Does it support files and forms?
Yes. -F fields become data entries and @filename values become files entries using open(..., 'rb').
Why does it warn about authorization and cookies?
Copied browser commands can contain session cookies or API tokens that grant account access. Mask or remove them before sharing.
Is the generated Python guaranteed to behave exactly like cURL?
Common HTTP options are translated, but shell expressions, proxies, certificates, and uncommon cURL transport flags may need manual review.
Which Python package does the output use?
The output uses the requests package. Install it with pip install requests if it is not already available.