Free, browser-based utilities for everyday developer workflows

Convert cURL to Python requests

Convert a cURL command into Python requests code, with query parameters and headers split out cleanly instead of jammed into the URL.

Open this example in cURL Converter

Open the tool, then paste the sample input below. Everything runs locally in your browser.

Open this example in cURL Converter →

The problem

A good translation uses params= for the query string and json= for JSON bodies, rather than building strings by hand. The converter produces idiomatic requests code you can drop into a script.

Sample input

cURL
curl -X GET "https://api.example.com/users?status=active" \
  -H "Authorization: Bearer example_token"

Expected output

Python requests
import requests

url = "https://api.example.com/users"
params = {
    "status": "active"
}
headers = {
    "Authorization": "Bearer example_token"
}

response = requests.get(url, params=params, headers=headers)
print(response.json())

The query string becomes a params dict and the header becomes a headers dict. For JSON bodies, use json= so requests sets the content type and serializes for you.

How to do it

  1. Paste the cURL command.
  2. Select Python requests output if available.
  3. Verify the query parameters and headers.
  4. Copy the generated Python code.
  5. Add a timeout and error handling for production use.

Common mistakes

  • Hardcoding real tokens in the script.
  • Omitting a timeout, so a hung request blocks forever.
  • Putting query parameters directly in the URL when params= is cleaner.
  • Using data= for JSON when json= is correct.
  • Not checking the HTTP status code before parsing the body.

Related tools

Related guides

FAQ

How do I convert cURL to Python requests?

Paste the cURL command and select Python requests output. The converter maps method, URL, headers, query params, and body into requests code.

Should I use json or data in requests?

Use json= for JSON payloads so requests serializes the object and sets Content-Type: application/json. Use data= for form-encoded bodies.

How do I pass headers in Python requests?

Pass a dict as headers=, for example headers={"Authorization": "Bearer example_token"}.

How do I add query parameters?

Pass a dict as params=, for example params={"status": "active"}; requests builds the query string for you.

Should I add a timeout?

Yes. Always pass timeout= so a slow or hung server cannot block your program indefinitely.

The conversion runs locally in your browser; your cURL command is never uploaded.