Convert a cURL command to fetch, Python, Go, PHP, Java or C# in one paste
API documentation, browser DevTools and support tickets all hand you requests as curl commands. This cURL to code converter parses the command the way a shell would — single and double quotes, $'…' strings, backslash line continuations, combined short flags such as -sSL and -XPOST — and rewrites it as working code in ten targets: JavaScript fetch, axios, Node.js https, undici, Python requests and httpx, Go net/http, PHP cURL, Java HttpClient and C# HttpClient.
Headers become an object or setter calls, a JSON body becomes a real object literal or dictionary, -u user:pass becomes each client's native Basic auth, -F uploads become multipart form data, and -L, -k, -m and --compressed map to the matching option. A summary shows the method, host, path, query, headers, body type and auth, and lists every option that was ignored, so nothing is dropped silently.
The command is parsed entirely in your browser. Nothing is sent to the URL and nothing leaves your device, so it is safe to paste commands that contain API keys, cookies or bearer tokens.
How to use the cURL to Code Converter
- Paste the command into the curl command box. Multi-line commands with trailing backslashes (or
^from Windows cmd and backticks from PowerShell) work as they are. - Check the parsed summary. Yellow notes list anything that was ignored or changed.
- Pick an output: fetch, axios, Node https, undici, Python requests, Python httpx, Go, PHP, Java or C#.
- Press Copy code, or Download to save it as a ready-named file such as
main.goorMain.java. - Replace placeholders such as
fileInput.files[0]for uploads, then run it. Comments point out options that behave differently in that language.
cURL to Code Converter features
Real shell parsing
Single quotes, double quotes with escapes, ANSI-C $'\n' strings, line continuations and --option=value forms all parse correctly.
JSON bodies as objects
A JSON -d body becomes JSON.stringify({ … }) in JavaScript and a json=payload dict in Python, with true, false and null turned into True, False and None.
Code that compiles
Go imports only the packages the snippet uses, Java and C# put content headers where their clients expect them, and PHP keeps the exact bytes curl would send.
Form and urlencoded data
-F name=@file becomes FormData, files=, CURLFile, mime/multipart or MultipartFormDataContent; -G moves the data into the query string.
Unsupported flags flagged
Options that only affect curl itself, such as -o, -w or --retry, are listed as ignored instead of vanishing.
How curl options map to each client
Most curl flags have a direct equivalent. Where a client behaves differently from curl, the code gets a short comment instead of a silent change.
| curl | JavaScript fetch | Python requests / httpx | Go · PHP · Java · C# |
|---|---|---|---|
-X PATCH | method: "PATCH" | requests.patch() | NewRequest("PATCH", …) · CURLOPT_CUSTOMREQUEST · .method("PATCH", …) · HttpMethod.Patch |
-d '{"a":1}' | body: JSON.stringify({ a: 1 }) | json=payload | strings.NewReader · CURLOPT_POSTFIELDS · ofString · StringContent |
-F file=@x.png | FormData | files={"file": (…)} | CreateFormFile · CURLFile · multipart bytes · MultipartFormDataContent |
-u user:pass | Authorization: Basic … | auth=("user", "pass") | SetBasicAuth · CURLOPT_USERPWD · Basic header · AuthenticationHeaderValue |
-L | redirect: "follow" | allow_redirects / follow_redirects=True | default · CURLOPT_FOLLOWLOCATION · Redirect.NORMAL · default |
-m 10 | AbortSignal.timeout(10000) | timeout=10 | Timeout: 10 * time.Second · CURLOPT_TIMEOUT · .timeout(…) · Timeout |
-k | not possible in browsers | verify=False | InsecureSkipVerify · CURLOPT_SSL_VERIFYPEER · custom SSLContext · validator callback |
Things to know before you run the code
- Redirects differ. curl follows redirects only with
-L. Go and .NET follow by default, so their snippets switch that off unless-Lis present; httpx, PHP and Java do not follow by default. - Browsers restrict some headers.
Cookie,User-AgentandHostcannot be set by fetch or axios in a web page; they work in Node and every server-side language. Java rejectsHostandContent-Lengthas restricted headers, so they are left out with a note. - CORS applies to browser requests. A command that works in a terminal may be blocked in a page if the API does not send
Access-Control-Allow-Origin. - Decompression varies. Go, PHP (
CURLOPT_ENCODING), httpx and .NET decode gzip for you; Node https and JavaHttpClientdo not, and the snippets say so.
Where to find curl commands to convert
Chrome, Edge and Firefox DevTools copy any request from the Network panel as curl (right-click → Copy → Copy as cURL). Open a whole recording in the HAR File Viewer to pick the right request first; the JSON Formatter makes the response readable and the HTTP status code reference explains anything other than a 200.
cURL to Code Converter FAQ
Is the request sent anywhere when I convert a curl command?
No. The converter only parses the text and generates code. It never contacts the URL, and your headers, tokens and cookies stay in your browser.
How do I convert curl to Python?
Paste the command and choose Python requests or Python httpx. Headers, cookies and JSON become dictionaries, and -u, -L, -k and -m become auth=, redirect, verify=False and timeout= arguments. httpx uses content= for raw text and httpx.request() when a GET carries a body.
Which curl options does the cURL converter understand?
-X, -H, -d/--data, --data-raw, --data-binary, --data-urlencode, --json, -F/--form, --form-string, -u, --oauth2-bearer, -b, -A, -e, -L, -k, -G, -I, -m, --compressed and --url. Display flags such as -s and -v are skipped; curl-only options such as -o, -w or --retry are listed as ignored in the summary.
Why does the generated fetch code not include my Cookie header?
It does, but browsers silently drop “forbidden” headers such as Cookie and User-Agent. The code adds a comment with the alternative, credentials: "include". In Node and the other languages they are sent normally.
Does the Go code compile without changes?
It is a complete package main that imports exactly the packages it uses. Replace file paths and secrets, then go run main.go.
Why is the body sent as JSON when curl would send form data?
Without a Content-Type header curl labels every -d body application/x-www-form-urlencoded, even JSON. Because that is almost never intended, the converter adds Content-Type: application/json when the body parses as JSON and shows a note. Add your own Content-Type to override it.