curl command converter

Parse a curl command into method, URL, headers, body and options, with equivalent Python and JavaScript code.

Input

The curl command line.

Result

Fill in the input and press Run.

Your input is processed in memory and then discarded. It is not stored or logged. Even so, don't paste live passwords or keys into any online tool.

Use it from code or an agent

curl -s https://setget.net/v1/tools/curl-to-json \
  -H 'Content-Type: application/json' \
  -d '{"input":{"command":"curl -X POST https://api.example.com/items -H '"'"'Content-Type: application/json'"'"' -d '"'"'{\"name\":\"x\"}'"'"'"}}'
import json, urllib.request

body = {'input': {'command': 'curl -X POST https://api.example.com/items -H \'Content-Type: application/json\' -d \'{"name":"x"}\''}}
request = urllib.request.Request("https://setget.net/v1/tools/curl-to-json", json.dumps(body).encode(),
                                 {"Content-Type": "application/json"})
print(json.load(urllib.request.urlopen(request))["result"])
const response = await fetch("https://setget.net/v1/tools/curl-to-json", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"command":"curl -X POST https://api.example.com/items -H 'Content-Type: application/json' -d '{\"name\":\"x\"}'"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "curl-to-json",
  "input": {
    "command": "curl -X POST https://api.example.com/items -H 'Content-Type: application/json' -d '{\"name\":\"x\"}'"
  }
}
{
  "input": {
    "command": "curl -X POST https://api.example.com/items -H 'Content-Type: application/json' -d '{\"name\":\"x\"}'"
  }
}

Endpoint: POST /v1/tools/curl-to-json. Over MCP: run_tool with slug: "curl-to-json". Machine-readable: input schema, Markdown. Connect an agent.

Inputs

NameTypeRequiredWhat it does
command string yes The curl command line.

Examples

Input
{
  "command": "curl -X POST https://api.example.com/items -H 'Content-Type: application/json' -d '{\"name\":\"x\"}'"
}
Result
{
  "method": "POST",
  "url": "https://api.example.com/items",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": "{\"name\":\"x\"}",
  "form": [],
  "options": {
    "follow_redirects": false,
    "insecure": false,
    "compressed": false,
    "auth": null,
    "timeout": null,
    "proxy": null
  },
  "unknown_flags": [],
  "python": "import requests\n\nresponse = requests.request(\n    'POST',\n    'https://api.example.com/items',\n    headers={\n        'Content-Type': 'application/json',\n    },\n    data='{\"name\":\"x\"}',\n    allow_redirects=False,\n)\nprint(response.status_code)\nprint(response.text)",
  "javascript": "const response = await fetch(\"https://api.example.com/items\", {\n  method: \"POST\",\n  headers: {\n    \"Content-Type\": \"application/json\"\n  },\n  body: \"{\\\"name\\\":\\\"x\\\"}\",\n  redirect: \"manual\"\n});\nconsole.log(response.status);\nconsole.log(await response.text());"
}

Combined flags, login and -G

Input
{
  "command": "curl -sL -u sam:secret \"https://example.com/search\" -G -d q=tea --frobnicate"
}
Result
{
  "method": "GET",
  "url": "https://example.com/search?q=tea",
  "headers": {},
  "body": null,
  "form": [],
  "options": {
    "follow_redirects": true,
    "insecure": false,
    "compressed": false,
    "auth": {
      "user": "sam",
      "password": "secret"
    },
    "timeout": null,
    "proxy": null
  },
  "unknown_flags": [
    "--frobnicate"
  ],
  "python": "import requests\n\nresponse = requests.request(\n    'GET',\n    'https://example.com/search?q=tea',\n    auth=('sam', 'secret'),\n)\nprint(response.status_code)\nprint(response.text)",
  "javascript": "const response = await fetch(\"https://example.com/search?q=tea\", {\n  method: \"GET\",\n  headers: {\n    \"Authorization\": \"Basic c2FtOnNlY3JldA==\"\n  }\n});\nconsole.log(response.status);\nconsole.log(await response.text());"
}

Questions

Is the request sent?
No. The command is only read and translated. Nothing is contacted.
What happens to flags the tool does not know?
They are listed under unknown_flags and otherwise ignored. If such a flag takes a value, that value may be mistaken for the URL, so check the result.
Why does the Python code say allow_redirects=False?
curl does not follow redirects unless you pass -L, while requests does by default. The code keeps the behaviour of your command.
Are files named with @ read?
No. A value such as -d @body.json is kept as written, because this tool cannot see your files.