HTTP request code builder

Turn a method, URL, headers and body into ready-to-run curl, Python requests and JavaScript fetch code.

Input

The address to request.
The HTTP method.
Request headers as a JSON object of names and values.
The request body, exactly as it should be sent.

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/http-request-build \
  -H 'Content-Type: application/json' \
  -d '{"input":{"url":"https://api.example.com/items","method":"post","headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Sam'"'"'s\"}"}}'
import json, urllib.request

body = {'input': {'url': 'https://api.example.com/items', 'method': 'post', 'headers': {'Content-Type': 'application/json'}, 'body': '{"name": "Sam\'s"}'}}
request = urllib.request.Request("https://setget.net/v1/tools/http-request-build", 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/http-request-build", {
  method: "POST",
  headers: {"Content-Type": "application/json"},
  body: JSON.stringify({"input":{"url":"https://api.example.com/items","method":"post","headers":{"Content-Type":"application/json"},"body":"{\"name\": \"Sam's\"}"}}),
});
console.log((await response.json()).result);
Tool: run_tool
Arguments:
{
  "slug": "http-request-build",
  "input": {
    "url": "https://api.example.com/items",
    "method": "post",
    "headers": {
      "Content-Type": "application/json"
    },
    "body": "{\"name\": \"Sam's\"}"
  }
}
{
  "input": {
    "url": "https://api.example.com/items",
    "method": "post",
    "headers": {
      "Content-Type": "application/json"
    },
    "body": "{\"name\": \"Sam's\"}"
  }
}

Endpoint: POST /v1/tools/http-request-build. Over MCP: run_tool with slug: "http-request-build". Machine-readable: input schema, Markdown. Connect an agent.

Inputs

NameTypeRequiredWhat it does
url string yes The address to request.
method string no The HTTP method. Default: "GET".
headers json no Request headers as a JSON object of names and values.
body string no The request body, exactly as it should be sent.

Examples

Input
{
  "url": "https://api.example.com/items",
  "method": "post",
  "headers": {
    "Content-Type": "application/json"
  },
  "body": "{\"name\": \"Sam's\"}"
}
Result
{
  "curl": "curl -X POST 'https://api.example.com/items' \\\n  -H 'Content-Type: application/json' \\\n  --data-raw '{\"name\": \"Sam'\\''s\"}'",
  "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\": \"Sam\\'s\"}',\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\\\": \\\"Sam's\\\"}\"\n});\nconsole.log(response.status);\nconsole.log(await response.text());"
}

A plain GET

Input
{
  "url": "https://example.com/health"
}
Result
{
  "curl": "curl 'https://example.com/health'",
  "python": "import requests\n\nresponse = requests.request(\n    'GET',\n    'https://example.com/health',\n)\nprint(response.status_code)\nprint(response.text)",
  "javascript": "const response = await fetch(\"https://example.com/health\", {\n  method: \"GET\"\n});\nconsole.log(response.status);\nconsole.log(await response.text());"
}

Questions

Is the request sent?
No. Only the code is produced. Run it yourself to make the request.
How are quotes in my data handled?
Each snippet escapes them for its own language, so the body arrives exactly as you wrote it.
Why is my JSON body a string?
The body is sent as written, byte for byte. Set the Content-Type header yourself, for example to application/json.