Developer
cURL to Python Requests
Convert a cURL request to Python requests code with headers, body and basic authentication. Redact common secrets before sharing.
Generates code locally; it does not send requests. Redaction covers common header, query and body secret names; review the output for custom secrets. Unsupported flags produce an error.
Ready to run. Input limit: 1 MB characters.
Output
—
Output actions
Ready to copy output once your result appears.
cURL to Python Requests mini guide
Convert a cURL request to Python requests code with headers, body and basic authentication. Redact common secrets before sharing.
How to use cURL to Python Requests
- 1Paste one literal cURL command using POSIX shell quotes, or Load sample.
- 2Choose Redact secrets; for Fetch choose Browser or Node.js runtime.
- 3Select Convert cURL, review the generated code and copy or download it.
What it is good for
- • Turn a copied HTTP request into a Python script.
- • Preserve headers and literal request bodies.
- • Redact common credentials before sharing an example.
Example
Input
curl 'https://api.example.com/users' -H 'Accept: application/json'
Output
import requests
response = requests.get("https://api.example.com/users", headers={"Accept":"application/json"}, timeout=30)
print(response.text)Rules and limitations
Headers, explicit request methods, literal request bodies, cookie strings and basic authentication are preserved. Body input infers POST when no method is supplied. Repeated header names use the final value in the generated header mapping. Transport flags such as --compressed and --location are accepted but do not configure a separate network connection here.
Redaction defaults on and masks common Authorization, Cookie, API key, token, secret and password names in headers, query parameters and structured JSON or form bodies. Custom credential names can escape detection. Inspect the output before sharing it; disable redaction only when you deliberately need the actual credentials in local code.
The output uses Python requests with a timeout, status checking and UTF-8 encoded body data. Install requests in your Python environment before running it; the generated snippet does not install packages for you.
Common problems
Supports one HTTP or HTTPS request. File uploads, @file bodies, --data-urlencode, shell substitutions, pipelines and unsupported flags produce explicit errors. PowerShell and Windows cmd quoting are not parsed.
Conversion generates text only. It does not test API credentials, contact the remote server or guarantee the service will accept the request.
Frequently asked questions
Are API calls made during conversion?
No. The cURL input is parsed locally and converted to code.
Does it preserve authentication?
Basic auth and explicit authentication headers are supported; redaction masks them by default.
Can it convert file uploads?
No. Local files and multipart upload flags are unsupported.
Why does browser Fetch fail with CORS?
The remote server must permit your origin. Code generation cannot change its CORS policy.
Is my input uploaded or saved?
This tool processes input in your browser and does not save its input or output to local storage. Copy and download are user actions. The site uses analytics for page and action metadata and may use ads and production error reporting; see the Privacy Policy for those services.
About this tool
Maintained by Toolbench. For large or deeply nested files, split the input into smaller batches and verify representative results before using them in an import or application. Report reproducible problems through Contact.
Continue with a practical guide
Turn a browser request into Python or JavaScriptCapture one request as cURL, convert it to requests or fetch, and review credentials and browser restrictions.
Related tools
Continue the workflow with nearby tools for formatting, publishing, debugging, or follow-up checks.
cURL to JavaScript Fetch
Convert cURL commands to JavaScript fetch code for browsers or Node.js. Preserve request headers and bodies with optional secret redaction.
URL and Query String Parser
Break down a URL into its components and query parameters.
JSON Formatter
Format or minify JSON with configurable indentation.
JSON Compare Online
Compare two JSON blobs with structural diff.