TapCub is live — analytics, insights and live chat, free on one platform

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.

Converter

Line breaks with \ (bash), ^ (cmd) or ` (PowerShell) are fine. Variables like $TOKEN are kept as text.

Parsed a POST request to api.pathclue.com.

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.
Code
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.

PartValue
MethodPOST
URLhttps://api.pathclue.com/api/v1/track
Header AuthorizationBearer wck_…
Header Content-Typeapplication/json
BodyJSON
Runs entirely in your browser. Nothing you type here is uploaded or stored by TapCub.

Version v1.0Updated Update history

Read the result

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.

How to use it

Three steps

Nothing is run and nothing is sent.

  1. 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. 2

    Pick the language

    fetch for front-end code, Node.js for scripts and servers, or Python, PHP, Go or Java.

  3. 3

    Copy and clean up

    Copy the code, move tokens and cookies into environment variables, and remove browser-only headers you do not need.

Supported options

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 options and how they are converted
curl optionMeaningIn Python requests
-X, -I, -GMethod; HEAD; data goes into the query stringrequests.post(…), requests.head(…), query appended to the URL
-H, -A, -eHeader; User-Agent; Refererheaders={…}
-d, --data-raw, --data-binary, --data-urlencodeBody, form-encoded by defaultdata={…} or data='…'
--json, or -d with a JSON Content-TypeJSON bodyjson={…}
-F, --form-stringmultipart/form-data, @file uploads a filefiles={…}
-u, -bBasic auth; cookiesauth=(…), cookies={…}
-L, -k, -m, --compressedFollow redirects; skip TLS checks; timeout; accept gzipFollowed by default, verify=False, timeout=, automatic
Worked example

One request, six languages

How the sample command (a JSON POST with a bearer token) is written in each language.

The sample curl command converted to six languages
LanguageRequest callJSON bodyHeaders
JavaScript (fetch)await fetch(url, { method: 'POST', … })body: JSON.stringify({…})headers: {…}
Node.jsSame as fetch (built in since Node 18)body: JSON.stringify({…})headers: {…}
Pythonrequests.post(url, …)json=json_dataheaders=headers (Content-Type left to requests)
PHPcurl_setopt_array($ch, […])CURLOPT_POSTFIELDS => json_encode([…])CURLOPT_HTTPHEADER
Gohttp.NewRequest("POST", url, body)strings.NewReader(`{…}`)req.Header.Set(…)
JavaHttpRequest.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.

Common mistakes

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.

FAQ

cURL 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.

Changelog

Update history

New features, fixes and data refreshes for this tool, newest first.

  1. · 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

See your data clearly. Find your growth.

Every click, backed by data. Install one line of code and see your first numbers in a minute.

No credit card · Free plans for analytics and chat · Cookieless analytics