cURL converter
cURL to code, proxy included
Paste a curl command and get Python, Node.js, Go or PHP that sends the same request. The -x proxy comes across the way each library wants it, with the password read from the environment rather than written into your code.
Converted in your browser as you type. Nothing you paste is sent to a server.
Off by default: the code reads the proxy from environment variables, so the password stays out of source control. Credentials for the target site (-u, headers) are copied as they are.
What changed
Every option in the command was converted.
import os
import requests
proxy = os.environ["PROXY_URL"]
proxies = {"http": proxy, "https": proxy}
headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"X-Request-Id": "7f3c2a",
}
payload = {
"query": "wireless earbuds",
"country": "de",
"page": 1,
}
response = requests.post(
"https://httpbin.org/anything?source=proxyhive",
headers=headers,
json=payload,
proxies=proxies,
timeout=30,
allow_redirects=False,
)
print(response.status_code, response.text)
Before you run it
pip install requests export PROXY_URL=http://USERNAME:PASSWORD@HOST:8080
Setup, SOCKS5, rotation and errors are covered in the Python requests proxy guide.
About this Python requests code
- requests has no deadline for the whole request: the timeout caps the connect and each wait for data, not the total as -m does.
How we checked the output
We ran what each generator writes, for a set of commands covering JSON and form bodies, repeated headers, redirects, Basic auth, HTTP and SOCKS5 proxies, through a local proxy that refuses a wrong username or password. Every request went to an echo service, and we compared the method, URL, headers and body it saw with what curl itself sent. Where a library still differs from curl, the page says how, next to the code.
Where each library takes the proxy
Python requests takes a proxies dict and httpx a proxy= argument. Node.js needs fetch and ProxyAgent from the same undici package, Go sets http.ProxyURL on the transport, and PHP uses CURLOPT_PROXY. Each guide covers authentication, SOCKS5, rotation and the errors you will meet. To test the proxy from the shell first, start with the cURL proxy guide.
Questions
Is the command I paste sent anywhere?
No. The parser and the five code generators run in your browser, and the page makes no request with what you type. That matters when a command carries a proxy password or an API token.
Why does the code read PROXY_URL instead of my password?
Code gets committed, and a password in a repository is a password shared with everyone who can read it. By default the proxy comes from environment variables, and the page prints the export line with your values to run in the shell. Tick "Keep proxy credentials in the code" to write them in.
Which curl options does it convert?
The method, headers, every -d form including --data-urlencode and --json, -G, -u, -A, -b, -e, -L, -k, --compressed, the timeouts, and the proxy from -x, -U, --socks5 or --socks5-hostname. Anything else is listed under the command, never dropped without a word.
Does it handle SOCKS5 proxies?
Yes, in all five. requests and httpx need their socks extra, Node uses undici's Socks5ProxyAgent, and Go and PHP need nothing extra. httpx, Go and undici always resolve hostnames on the proxy, so socks5:// behaves like socks5h:// there; the page says so when it applies.
Start free
Point the code at a real proxy
Every account starts with 1 GB free. Static ISP proxies are sold from one IP, and the order page lists the host, port and credentials this code reads.