Free tool cURL converter: turn curl commands into code
API docs show curl; your app needs Python, JavaScript, PHP, Go or Java. Paste the command, including one copied from your browser’s Network tab, and get the same request as working code: method, URL, headers, JSON or form body, file uploads, basic auth, cookies and timeouts.
- 6 target languages
- Bash, cmd and PowerShell quoting
- Parsed locally, never run
Convert a curl command
The sample sends one purchase event to TapCub’s server API, as in our docs. Paste your own command; the code updates as you type.
Line breaks with \ (bash), ^ (cmd) or ` (PowerShell) are fine. Variables like $TOKEN are kept as text.
Checks
- WarningContains credentials (Authorization). They stay in this page, but remove them before sharing the code or committing it; load them from environment variables instead.
const response = await fetch('https://api.pathclue.com/api/v1/track', {
method: 'POST',
headers: {
'Authorization': 'Bearer wck_…',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"events": [
{
"event": "purchase",
"login_id": "u_123",
"insert_id": "order-1001",
"properties": {
"revenue": 19.9
}
}
]
})
});
console.log(response.status);
console.log(await response.text());Parsed request
What the command sends, so you can check the conversion.
| Part | Value |
|---|---|
| Method | POST |
| URL | https://api.pathclue.com/api/v1/track |
| Header Authorization | Bearer wck_… |
| Header Content-Type | application/json |
| Body | JSON |
Version v1.0Updated Update history
Check the conversion in three places
Code that looks right can still send a different request. These are the parts worth a second look.
Parsed request
The table under the code lists the method, URL, every header and the body type exactly as curl would send them. If something is missing there, the command was cut off or quoted differently than you think.
Method
curl switches to POST when you add -d or -F, and to GET with -G. The sample has an explicit -X POST, so the code uses POST either way.
Body type
A JSON body becomes a native object (json= in Python, JSON.stringify in JavaScript, an array in PHP), so you can edit it as data. Form data becomes field pairs; -F becomes a multipart upload.
Checks
Warnings flag credentials in the command, disabled certificate checks, files the code has to read, and options that could not be converted.
The sample key wck_… is the placeholder from our docs, which is why the credentials warning appears. A real key would trigger the same warning.
Three steps
Nothing is run and nothing is sent.
-
1
Copy the command
From API docs, a terminal, or your browser: in the Network tab, right-click a request and choose Copy as cURL (bash or cmd both work).
-
2
Pick the language
fetch for front-end code, Node.js for scripts and servers, or Python, PHP, Go or Java.
-
3
Copy and clean up
Copy the code, move tokens and cookies into environment variables, and remove browser-only headers you do not need.
What the converter understands
The parser follows the curl manual. Options that only change curl’s own output (-s, -v, -o, -i) are ignored because they do not change the request.
- Quoting: single and double quotes,
$'…', backslash escapes and line continuations in bash;^in Windows cmd; backtick in PowerShell - Short options can be combined (
-sSL) or attached (-XPOST) - Without a scheme, a URL gets
http://, as curl does
| curl option | Meaning | In Python requests |
|---|---|---|
-X, -I, -G | Method; HEAD; data goes into the query string | requests.post(…), requests.head(…), query appended to the URL |
-H, -A, -e | Header; User-Agent; Referer | headers={…} |
-d, --data-raw, --data-binary, --data-urlencode | Body, form-encoded by default | data={…} or data='…' |
--json, or -d with a JSON Content-Type | JSON body | json={…} |
-F, --form-string | multipart/form-data, @file uploads a file | files={…} |
-u, -b | Basic auth; cookies | auth=(…), cookies={…} |
-L, -k, -m, --compressed | Follow redirects; skip TLS checks; timeout; accept gzip | Followed by default, verify=False, timeout=, automatic |
One request, six languages
How the sample command (a JSON POST with a bearer token) is written in each language.
| Language | Request call | JSON body | Headers |
|---|---|---|---|
| JavaScript (fetch) | await fetch(url, { method: 'POST', … }) | body: JSON.stringify({…}) | headers: {…} |
| Node.js | Same as fetch (built in since Node 18) | body: JSON.stringify({…}) | headers: {…} |
| Python | requests.post(url, …) | json=json_data | headers=headers (Content-Type left to requests) |
| PHP | curl_setopt_array($ch, […]) | CURLOPT_POSTFIELDS => json_encode([…]) | CURLOPT_HTTPHEADER |
| Go | http.NewRequest("POST", url, body) | strings.NewReader(`{…}`) | req.Header.Set(…) |
| Java | HttpRequest.newBuilder().POST(…) | BodyPublishers.ofString("…") | .header(…) |
Redirects differ by language: curl follows them only with -L. fetch, requests and Go follow by default; PHP cURL and Java HttpClient do not, so the code turns following on only when the command has -L.
Why converted code behaves differently
Most differences come from the environment, not from the conversion.
Browser-only headers
A command copied from Chrome carries Cookie, User-Agent, sec-ch-ua and similar headers. Browsers refuse to set some of them from fetch, and servers may reject a stale session cookie. Keep only what the API needs.
Tokens pasted into code
Bearer tokens, API keys and session cookies end up in source control easily. Read them from environment variables, and rotate any key that was shared.
CORS in the browser
curl ignores CORS; a browser does not. If the API does not allow your site’s origin, the fetch version fails where curl worked. Call it from your server instead.
Shell variables and files
$TOKEN and @body.json are expanded by the shell or by curl. The code keeps $TOKEN as text and reads @file where it can; replace them with real values.
Send server-side events with one HTTP request
Orders, refunds and anything that never happens in a browser can be sent to TapCub from your backend, as in the sample command.
Server API
Send named events from the backend with a Server Key, into the same project as your web and app data.
Learn moreData-quality checks
Unexpected event names, missing properties and wrong types are flagged; duplicates can be merged or renamed.
Learn moreCustom events and properties
Track orders, sign-ups or any business action with the fields you care about, then chart and filter by them.
Learn morecURL converter questions
Still have a question?
Chat with the team behind TapCub — we usually reply within a few hours on business days.
How do I convert a curl command to code?
Paste the whole command, starting with curl, choose a language, and copy the code. The table under it shows the request as parsed, so you can check that nothing was lost.
How do I get a curl command from my browser?
Open developer tools, go to the Network tab, right-click the request and choose Copy → Copy as cURL. Both the bash and the cmd (Windows) versions can be pasted here.
Is the command executed or sent anywhere?
No. It is parsed as text in your browser; nothing is run and no request is made. That is also why $VARIABLES and @files are not expanded.
Why does the fetch code fail in the browser when curl works?
Usually CORS: browsers only let a page call an API that allows its origin, and they refuse to set headers such as Cookie or Host. Run the Node.js version on a server, or ask the API owner to allow your origin.
Which curl options are supported?
The ones that change the request: -X, -H, -d and its variants, --json, -F, -G, -I, -u, -b, -A, -e, -L, -k, -m and --compressed. Others are listed in the checks as ignored or not converted.
What happens to my API key in the command?
It stays on this page, and the checks point it out. Before you share or commit the generated code, replace the key with an environment variable such as os.environ["API_KEY"] or process.env.API_KEY.
Update history
New features, fixes and data refreshes for this tool, newest first.
-
· v1.0
LaunchedFirst release.
Missing something or found an error? Tell us — requests that come up often go into the next update. All tool updates
Inspect what the server sends back
Once the request works, check the response: status, headers, redirects and caching.