How to use cURL to Python Requests
- Paste a command beginning with curl and one absolute HTTP or HTTPS URL. Quote URLs containing shell query characters.
- Use supported request, header, or inline-body options. Remove file reads, variables, shell operators, and unsupported flags.
- Select Convert and review the method, URL, headers, body, redirect setting, and added timeout.
- Copy the code into your own Python environment with Requests installed. Review credentials and target permissions before you choose to run it.
A deliberately bounded cURL subset
Supported options are -X/--request, -H/--header, -d/--data, --data-raw, --data-binary, --json, --url, -I/--head, -L/--location, -s/--silent, and -S/--show-error. Attached short values and long --option=value forms are accepted. POSIX-style single and double quotes and escaped line continuations are understood.
Only one literal URL, one explicit method, one literal body, and unique, non-empty headers are supported. URL glob patterns and header suppression syntax are rejected. Multipart forms, file-backed bodies, cookies, proxies, TLS options, authentication flags, Windows shell syntax, and other flags require manual conversion. Shell variables, substitutions, redirection, comments, and unquoted operators are rejected instead of executed.
Review the generated request
Without an explicit method, an inline body selects POST, --head selects HEAD, and an ordinary URL selects GET. The generated request follows redirects only when -L/--location was provided. It adds a 30-second timeout. Those choices are visible in the code rather than hidden in the UI.
Inline data receives cURL's usual form content type unless a Content-Type header was supplied; --json receives JSON Content-Type and Accept headers when absent. The body remains a literal string. This converter does not infer JSON schema, reproduce every cURL transport behavior, or guarantee identical server responses: default client headers and transport details can differ.
The input remains code text
The conversion function tokenizes text in the browser and emits Python string literals. It does not use eval, launch curl, install Requests, resolve a target host, read a local file, or send your headers or body to a conversion server.
Input is limited to 200,000 UTF-16 units and 256 cURL arguments. A request body beginning with @ is rejected in this subset; --data and -d bodies containing newlines are also rejected, with --data-raw available for literal newlines. Keep real credentials out of examples you share with other people.
Which format do you need?
| Your next task | Input or choice | Output or result |
|---|---|---|
| Convert a simple request | A cURL command specifies supported request options. | Requests code shows a corresponding method, URL, headers, and body. |
| Use files or shell variables | A shell may expand variables or read files. | The converter rejects those operations and runs nothing. |
| Match every transport detail | cURL supports many connection and TLS controls. | This subset does not reproduce every client behavior. |
Questions about this tool
Does conversion send the HTTP request?
No. The page generates Python code text. It does not execute curl, Python, or a network request to the pasted target.
Can it read @file bodies or environment variables?
No. File-backed bodies and shell expansions are unsupported. Paste a literal inline body and explicit values instead.
Why are duplicate headers rejected?
The generated Requests code uses a header dictionary, which cannot represent repeated field names reliably. This converter rejects duplicates instead of silently overwriting one.
Are redirects and timeouts preserved?
Redirect following is enabled only for -L/--location. The generated code adds a 30-second timeout, which you should review before running it.
Does it support every cURL flag?
No. It supports the listed literal HTTP subset. Unsupported options produce an error so you can convert them manually rather than lose their behavior silently.