curl Converter API

Convert a curl command into fetch, axios, Python requests, PHP, Go, Java, C#, Ruby, Node.js, wget or HTTPie code, with headers, body and query as JSON.

GETPOSThttps://apibox.io.vn/v1/curl-convert
Developer utilities▶ Try it online

Paste a curl command, for example from an API’s documentation or from the browser’s "Copy as cURL" (bash or Windows cmd), and get equivalent code for JavaScript fetch, axios, Python requests, PHP curl, Go net/http, Java HttpClient, C# HttpClient, Ruby Net::HTTP, Node.js http / https, wget and HTTPie. to selects targets (comma-separated, default all). The response also has the parsed request: method, URL, query parameters, headers, body (JSON, form, multipart parts or a file reference) and auth, handy to feed a no-code HTTP step.

The command line is parsed by our own POSIX shell-word parser: single and double quotes, backslash escapes, $'…' ANSI-C strings, line continuations with \, ^ (cmd) or backtick (PowerShell). Supported options: -X, -H, -d / --data / --data-raw / --data-binary / --data-urlencode, --json, -F / --form, -u, --oauth2-bearer, -b, -A, -e, -k, -L, -I, -G, --compressed, -x, --url, --url-query, -o, -m, combined short flags (-sSL) and --opt=value.

Harmless display options (-s, -v, -i, --retry…) are listed in ignored_options; options we do not translate are listed in unsupported_options, and warnings explain approximations (files read with @, cookies from a file, several URLs). Nothing is sent to the URL in the command.

Parameters

NameInTypeRequiredDefault
curlbody|querystringyesThe curl command (or send it as a raw text body).
tobody|querystringnoallTargets: fetch, axios, python, php, go, java, csharp, ruby, node, wget, httpie or all (comma-separated).

Example

curl -X POST "https://apibox.io.vn/v1/curl-convert" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"curl":"curl -X POST https://api.example.com/v1/orders -H '\''Content-Type: application/json'\'' -u key:secret -d '\''{\"sku\":\"A1\",\"qty\":2}'\''","to":"python"}'

Response

{
  "request": {
    "method": "POST",
    "url": "https://api.example.com/v1/orders",
    "full_url": "https://api.example.com/v1/orders",
    "query": {},
    "headers": {
      "Content-Type": "application/json"
    },
    "body": {
      "type": "json",
      "text": "{\"sku\":\"A1\",\"qty\":2}",
      "json": {
        "sku": "A1",
        "qty": 2
      }
    },
    "auth": {
      "user": "key",
      "password": "secret",
      "type": "basic"
    },
    "follow_redirects": false,
    "insecure": false,
    "compressed": false
  },
  "code": {
    "python": "import requests\n\njson_data = {\n    \"sku\": \"A1\",\n    \"qty\": 2,\n}\n\nresponse = requests.post(\"https://api.example.com/v1/orders\",\n    json=json_data,\n    auth=(\"key\", \"secret\"),\n    allow_redirects=False,\n)\nprint(response.status_code, response.text)\n"
  },
  "targets": {
    "python": "Python requests"
  }
}

Use cases

  • Turn the curl examples of a payment or shipping API into PHP or Python code
  • Replay a request copied from the browser DevTools in a script
  • Get headers and body as JSON for an n8n, Make or Apps Script HTTP step
  • Teach the same HTTP request in several languages

FAQ

Does the API call the URL in my command?

No. It only parses the text and generates code; no request is made to the URL.

What happens with -d @file or -F file=@photo.jpg?

The generated code reads the named file (open(), fs.readFileSync, CURLFile, os.Open…) and a warning reminds you that the file must exist where the code runs.

Is the Windows "Copy as cURL (cmd)" format supported?

Yes. ^ escapes and ^ line continuations from cmd, and backtick continuations from PowerShell, are handled before parsing.

Related APIs

Start with 1,000 free requests every month. Get free API key →