cURL to Code Converter
Paste a curl command and get equivalent code for fetch, axios, Python, Go, PHP or Java.
Use the bash/macOS/Linux syntax (in Chrome or Firefox DevTools: right-click a request → Copy → Copy as cURL (bash)).
Parsed request
- Method
- POST
- URL
- https://api.example.com/v1/users?team=core
- Headers
- Accept: application/jsonContent-Type: application/jsonAuthorization: Bearer YOUR_TOKEN
- Body
- {"name":"Alice","email":"alice@example.com","admin":false}
const response = await fetch("https://api.example.com/v1/users?team=core", {
method: "POST",
headers: {
"Accept": "application/json",
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN",
},
body: JSON.stringify({
"name": "Alice",
"email": "alice@example.com",
"admin": false
}),
});
const text = await response.text();
console.log(response.status, text);What this tool does
curl is the common language of HTTP. API documentation shows examples as curl commands, support teams ask for "the curl" to reproduce a bug, and every browser can copy any network request as a curl command. When it is time to put that request into an application, you need it in your programming language, with headers, body, authentication and method exactly right.
This converter reads the command the way a shell does — quotes, escapes, line continuations — then interprets the curl options the way curl does, and writes the same request as code. Before showing the code it displays a Parsed request summary, so you can confirm the method, URL, headers and body were understood correctly.
How to use it
- Paste a command into cURL command. To capture a request from a website, open DevTools → Network, right-click the request and choose Copy → Copy as cURL (bash).
- Check the Parsed request box and read any warnings.
- Pick a target: JavaScript (fetch), Node.js (axios), Python (requests), Go (net/http), PHP (cURL) or Java (HttpClient).
- Press Copy code or Download, then replace placeholder tokens with real secrets from your configuration.
Worked example
Input:
curl 'https://api.example.com/v1/users?team=core' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer YOUR_TOKEN' \
--data-raw '{"name":"Alice","admin":false}'There is no -X, but --data-raw makes curl send a POST, so the parsed method is POST. The Python (requests) output is:
import requests
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_TOKEN",
}
json_data = {
"name": "Alice",
"admin": False,
}
response = requests.post(
"https://api.example.com/v1/users?team=core",
headers=headers,
json=json_data,
allow_redirects=False,
)
print(response.status_code)
print(response.text)Because the Content-Type is JSON, the body becomes a Python dictionary (note False, not false) passed with json=. allow_redirects=False is there because curl does not follow redirects without -L. The fetch version passes the same object through JSON.stringify(...).
How curl options are translated
- -d / --data / --data-raw / --data-binary – the request body. Several -d flags are joined with &, as curl does. A JSON Content-Type turns the body into a native object or dictionary; otherwise it is sent as a string.
- --data-urlencode – the value is percent-encoded. With -G, all data is appended to the URL as a query string and the method stays GET.
- --json – sets the body plus Content-Type and Accept: application/json.
- -F / --form – multipart form data. name=@file.png becomes a file upload (FormData, files=, CURLFile, mime/multipart). The boundary header is left to the library.
- -u user:pass – HTTP Basic authentication using each library's own option, or a precomputed Authorization header for fetch and Java.
- -b, -A, -e – Cookie, User-Agent and Referer headers.
- -L – follow redirects. Python, Go, PHP, Java and axios output match curl's default of not following redirects when -L is absent; browsers always follow them in fetch.
- -k – disables certificate verification where the language allows it (axios, Python, Go, PHP). It is only a comment for fetch and Java.
- -I – a HEAD request. --compressed – automatic in most libraries; PHP gets CURLOPT_ENCODING.
Limitations
- Only bash-style quoting is parsed. Windows cmd (^ escapes) and PowerShell commands need to be re-copied as bash.
- Shell features such as $VARIABLES, $(commands) and pipes are not evaluated; variables are kept as literal text.
- Bodies loaded from files with -d @file or -T cannot be read; a warning is shown.
- Only the first URL is converted. Proxy, client certificate, timeout and retry options are ignored.
- Integers larger than 253 in a JSON body make the tool keep the body as a raw string to avoid changing the number.
Tips
- Requests copied from a browser contain session cookies and tokens. Remove them before sharing the code, and do not commit them.
- Browser copies include many headers the server does not need (sec-ch-ua, accept-language…). Delete them from the curl command first for cleaner code.
- Check JSON bodies with the JSON Formatter, inspect bearer tokens with the JWT Decoder, and inspect a site's response headers with the HTTP Headers Checker.
Frequently Asked Questions
Which languages can a cURL command be converted to?
JavaScript fetch, Node.js axios, Python requests, Go net/http, PHP cURL and Java HttpClient (Java 11+). Each output is a complete snippet with the language's own string escaping.
Does it work with Copy as cURL from Chrome or Firefox DevTools?
Yes, with the bash variant (Copy as cURL (bash), the default on macOS and Linux). It handles many -H flags, -b cookies, --data-raw with $'…' strings and --compressed. The Windows cmd and PowerShell variants use different quoting and are not supported.
Which curl options are understood?
-X, -H, -d, --data-raw, --data-binary, --data-urlencode, --json, -u, -b, -A, -e, -F, -G, -I, -L, -k, --compressed, --url and --oauth2-bearer. Output, timeout, proxy and certificate options are skipped, and the tool warns when something such as @file cannot be translated.
Why is my request a POST when there is no -X?
Because that is what curl does: -d, --data and -F switch the method to POST, and -d also adds Content-Type: application/x-www-form-urlencoded unless you set another one. The generated code reproduces that, so add -H 'Content-Type: application/json' for JSON bodies.
Why are some headers missing from the fetch code?
Browsers forbid scripts from setting headers such as Cookie, User-Agent, Origin, Referer and sec-*. The fetch output lists them in a comment instead of including code that would be silently ignored. The Node.js, Python, Go, PHP and Java outputs keep them.
Is my cURL command or token sent to a server?
No. Parsing and code generation happen in your browser and the request is never executed. Tokens and cookies in the command stay on your device, but remember they are still in the generated code you copy.
Related tools
- DNS LookupQuery DNS records (A, AAAA, MX, TXT, CNAME, NS, SOA) for any domain in real time.
- IP Address InfoGet detailed information about any IP address: geolocation, ISP, ASN, reverse DNS, abuse contacts.
- IP Subnet CalculatorCalculate IPv4 subnets, CIDR notation, network/broadcast addresses, and available host ranges. Supports VLSM and supernetting.
- HTTP Headers AnalyzerAnalyze HTTP headers from any URL
Found a bug or a wrong result? Report it.