Skip to content

cURL to Python requests

Turn a bounded cURL command into a reviewable Python requests snippet, entirely locally.

Supports URL, -X/--request, -H/--header, -d/--data, --url, -u and -I. The output is a static requests snippet.
Authorization, cookies and API-key headers stay redacted unless you explicitly opt in.
Generated Python preview300 characters
import requests

url = "https://api.example.com/v1/notes?limit=10"
headers = {
    "Content-Type": "application/json",
    "Authorization": "[redacted]",
}
response = requests.request("POST", url, headers=headers, data="{\"title\":\"Morning notes\"}")
print(response.status_code)
print(response.text)
Processed on your device

How it works & useful details

Local-only workspace

This tool converts or inspects pasted text in your browser. It never sends a request, opens a URL, uploads a HAR, or stores your input.

Supported cURL syntax

The same bounded cURL subset is converted into a static requests.request call. Review the generated snippet before using it in your own environment.

About this tool

cURL to Python requests turns a pasted cURL command into a readable Python snippet using the requests library. It is useful when an API example is only documented as a cURL command and you want the equivalent Python quickly.

The command is parsed in your browser and no request is made. Credentials in headers or data are redacted by default, so the snippet is safe to share or commit while you replace the values with your own environment variables.

How to use it

  1. Paste the cURL command.
  2. Check the detected method, URL, headers, and body in the parsed view.
  3. Generate the Python snippet and read any warnings about unparsed options.
  4. Copy the code and substitute credentials from your own configuration.

Worked example

The same POST command converts to:

import requests

url = "https://api.example.com/v1/notes?limit=10"
headers = {
    "Content-Type": "application/json",
    "Authorization": "[redacted]",
}
response = requests.request("POST", url, headers=headers, data="{\"title\":\"Morning notes\"}")
print(response.status_code)
print(response.text)

The body is passed through unchanged as data, exactly as cURL would send it. In your own code you could switch to json={"title": "Morning notes"} and let requests set the Content-Type header.

Making the snippet production-ready

  • Read tokens from an environment variable (os.environ["API_TOKEN"]) instead of pasting them into code.
  • Add a timeout, for example timeout=10. requests waits indefinitely by default.
  • Call response.raise_for_status() so HTTP errors raise an exception instead of passing silently.
  • Use a requests.Session() when making many calls to the same host, to reuse connections.

The converter accepts the same bounded cURL subset as cURL to fetch and rejects anything it cannot translate faithfully.

Frequently asked questions

Which cURL options are understood?

Common options such as request method, headers, data, output, and location following. Unsupported flags are reported so you know what was not converted.

Is my token sent anywhere?

No. Parsing and redaction happen locally in the page, and the generated snippet never leaves your browser.

What is the input limit?

Up to 40,000 characters per command. Split very long bodies or paste only the part you need to convert.

Does it support httpx or aiohttp?

It generates requests code. httpx has an almost identical API, so the snippet usually works after changing the import to httpx.