Free cURL to Code Converter

Paste a cURL command and get equivalent code for Python, JavaScript, PHP, Go or Ruby. The parser respects single and double quotes, line continuations and common cURL flags, so JSON bodies and headers are converted correctly instead of being split naively on spaces.

Convert a cURL command

Paste a command from your terminal, browser DevTools (“Copy as cURL”), or API documentation. The command is never uploaded.

Paste a cURL command to begin.
Generated code
Your generated code will appear here.

How to use the cURL converter

  1. Paste the cURL command into the input box. You can include line continuations (\ at the end of a line).
  2. Choose a target language. Python, JavaScript (fetch or axios), PHP, Go and Ruby are supported.
  3. Click Convert. The generated code appears on the right.
  4. Copy or download. Use the Copy button for the clipboard, or Download to save a file with the correct extension.

What this converter handles

Supported flags

cURL flags recognized by the converter
Flag Meaning Conversion behavior
-X, --requestHTTP methodSets the method directly.
-H, --headerRequest headerAdded to the headers object or array.
-d, --dataRequest bodySets the body; method becomes POST unless overridden.
--data-rawRaw bodySame as -d for conversion purposes.
--data-binaryBinary bodySame as -d for conversion purposes.
--data-urlencodeURL-encoded bodyJoined with & and passed as a body string.
--jsonJSON bodySets Content-Type and Accept to JSON, and passes the raw body.
-F, --formMultipart form fieldGenerates a form-data object; @file is marked as a file field.
-u, --userBasic authMaps to auth in Python/JavaScript, CURLOPT_USERPWD in PHP, etc.
-b, --cookieCookie headerAdds a Cookie header.
-A, --user-agentUser-Agent headerAdds a User-Agent header.
-e, --refererReferer headerAdds a Referer header.
-x, --proxyProxy URLMaps to the proxy option where supported.
-L, --locationFollow redirectsEnables redirect following where supported.
--no-locationDo not follow redirectsDisables redirect following.
-k, --insecureSkip TLS verificationDisables certificate verification where the language allows it.
-I, --headHEAD requestSets the method to HEAD.
-G, --getSend data as query stringAppends data to the URL and uses GET.
--compressedRequest compressed responseAdds Accept-Encoding: gzip, deflate, br.

Examples

JSON POST to Python requests

Input:

curl -X POST 'https://api.example.com/v1/users' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_TOKEN' \
  -d '{"name":"Ada Lovelace","email":"ada@example.com"}'

Output (Python):

import requests

url = "https://api.example.com/v1/users"

headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer YOUR_TOKEN",
}

data = '{"name":"Ada Lovelace","email":"ada@example.com"}'

response = requests.request("POST", url, headers=headers, data=data)

print(response.status_code)
print(response.text)

Multipart form to JavaScript fetch

Input:

curl -X POST 'https://api.example.com/upload' \
  -F 'name=report' \
  -F 'file=@/path/to/report.pdf'

The fetch output uses a FormData object. The file path is kept as a comment because a browser cannot read a local path directly; you must supply a File object from an <input type="file"> element.

Limitations to know

Frequently asked questions

Is this cURL converter free and private?

Yes. The converter is free and does not require an account. The command you paste is processed in your browser tab and is not uploaded to a server.

Does it handle JSON bodies with quotes correctly?

Yes. The tokenizer respects single and double quotes, so a JSON body wrapped in single quotes is not split on the spaces inside it. This is the main failure mode of simpler converters that split on whitespace.

Which languages are supported?

Python (requests), JavaScript (browser fetch), JavaScript (Node.js axios), PHP (cURL), Go (net/http) and Ruby (net/http).

Can I convert a command that uses -F for file uploads?

Yes, the form fields are parsed. File fields are marked as files. In Python, the generated code uses open(path, "rb"). In browser fetch, the generated code uses FormData and expects you to supply a File object, because a browser cannot read a local path.

Why does the tool warn about some flags?

Some cURL flags are about terminal output, retries, tracing or writing to a file. They do not map cleanly to an HTTP client library, or they would require platform-specific code. The converter warns you instead of silently ignoring them.

Does the generated code include error handling?

No. The snippets are intentionally minimal so they are easy to read and adapt. Add try/catch, status-code checks, timeouts and logging for production use.

Can I use this for API keys and tokens?

Yes, but review the generated code before sharing it. A cURL command copied from browser DevTools can contain cookies, bearer tokens or other secrets. The converter does not send the command anywhere, but the generated code will contain whatever credentials were in the command.

Why does the JavaScript fetch output mention redirect: "manual"?

cURL does not follow redirects by default. To preserve that behavior, the generated fetch code uses redirect: "manual" unless the command includes -L. Python requests follows redirects by default, so the generated Python code sets allow_redirects=False when -L is absent.