# curl command converter

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

- Endpoint: `POST https://setget.net/v1/tools/curl-to-json` with JSON `{"input": {...}}`
- MCP: `run_tool` with `slug` = `curl-to-json`
- Page: https://setget.net/tools/curl-to-json

## Inputs

- `command` (required, string): The curl command line.

## Example 1

```json
{"input":{"command":"curl -X POST https://api.example.com/items -H 'Content-Type: application/json' -d '{\"name\":\"x\"}'"}}
```

Result:

```json
{"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());"}
```

## Example 2: Combined flags, login and -G

```json
{"input":{"command":"curl -sL -u sam:secret \"https://example.com/search\" -G -d q=tea --frobnicate"}}
```

Result:

```json
{"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());"}
```

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