cURL to Python Requests Converter
Turn a literal cURL command into Python requests code without sending the HTTP request.
Runs in your browser. Your input stays on this device.
What this tool does
Translate supported literal cURL arguments into a Python requests snippet without executing it.
When to use it
Use a representative HTTP request as a starting point when moving a terminal fixture into an integration test.
How to use it
- Paste a literal cURL command with synthetic values.
- Select Convert to Python.
- Review method, URL, timeout, headers, body and redirects before running the snippet in your environment.
Worked example
Load the example request to example.com and convert it. Review the generated requests call. The URL, Accept header and JSON body should all be visible. When porting a browser request, start from a small request you can understand and remove sensitive headers and cookies before using an example in documentation. Inspect the generated timeout and any redirect option before running it in your own Python environment. Conversion is a text operation. Running the generated Python sends a real request to the address in the code.
curl 'https://example.com/api/items' -H 'Accept: application/json'import requests
response = requests.request(
"GET",
"https://example.com/api/items",
headers={"Accept":"application/json"},
allow_redirects=False,
timeout=30,
)
print(response.status_code)
print(response.text)Supported features and limitations
Supports one HTTP URL, headers, literal data, basic auth, cookies and redirects. Shell expansions, files, multipart forms and unsupported flags produce errors. Review any credentials before sharing the output.
Common mistakes and edge cases
The converter accepts literal arguments. Variables such as $TOKEN, substitutions that call other programs and arguments that load a local file depend on the shell or filesystem. Replace them with harmless test literals when building an example, then wire environment variables or file reads into your Python code explicitly. Multipart uploads and unsupported cURL options need a hand-written requests call. Make sure the generated request retains the content type your endpoint expects. For a request you plan to keep as a fixture, replace private hostnames and credentials with demonstration values before committing it. If the service expects raw bytes, compare the original request body with the body the Python client sends.
Frequently asked questions
- Can I use a command copied from a browser?
- Use the browser option that exports cURL with POSIX-style quoting. Check for cookies, authorization headers and other sensitive values before sharing either the command or its Python output.
- What should I verify before running the generated snippet?
- Check the target URL, method, headers, body, redirect behavior and timeout. Read the response and handle errors in your application before relying on the snippet in a recurring job.