[ advertisement ]

cURL to Code Converter

Paste a cURL command copied from DevTools or an API's documentation and get equivalent code with the method, headers, body and authentication.

cURL command

Code

const response = await fetch("https://api.example.com/v1/users", {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer <token>",
    },
    body: JSON.stringify({
        "name": "Ana",
        "active": true,
        "roles": [
            "admin"
        ]
    }),
});

const data = await response.text();
console.log(response.status, data);

Use via API

Converts a cURL command into code.

POSThttps://enhanced.dev.br/api/v1/convert/curl
JSON body parameters
Body (JSON)TypeDescription
command *stringFull cURL command.
target"fetch" | "python" | "go" | "lua"Output language. Default: "fetch".

Request example

curl -X POST "https://enhanced.dev.br/api/v1/convert/curl" \
    -H "Content-Type: application/json" \
    -d '{"command":"curl -X POST https://api.example.com/v1/users -H \"Content-Type: application/json\" -d '\''{\"name\":\"Ana\"}'\''","target":"python"}'

Response

{
  "ok": true,
  "data": {
    "target": "python",
    "code": "import requests\n\nheaders = {\n    \"Content-Type\": \"application/json\",\n}\n\njson_data = {\n    \"name\": \"Ana\",\n}\n\nresponse = requests.post(\"https://api.example.com/v1/users\", headers=headers, json=json_data)\nprint(response.status_code, response.text)",
    "request": {
      "method": "POST",
      "url": "https://api.example.com/v1/users",
      "headers": [
        [
          "Content-Type",
          "application/json"
        ]
      ],
      "body": "{\"name\":\"Ana\"}"
    },
    "warnings": []
  },
  "meta": {
    "version": "v1"
  }
}
  • Errors return { ok: false, error: { code, message } } with an HTTP 4xx/5xx status.
  • Free, no API key required. Limited to 120 requests per minute per IP.
  • CORS enabled: call it straight from the browser on any domain.
[ advertisement ]

How to use

  1. Paste the cURL command (line continuations with \ are supported).
  2. Choose the output language.
  3. Review the warnings about unsupported flags.
  4. Copy the generated code.

Use cases

  • Turning API documentation examples into ready-to-use code.
  • Reproducing a request copied from DevTools (Copy as cURL) in code.
  • Migrating shell scripts into applications.

Technical concepts

Supported flags

-X/--request, -H/--header, -d/--data/--data-raw/--data-binary, --data-urlencode, --json, -u/--user (converted into Authorization Basic), -A, -b, -e, -G and -I. Terminal behavior flags such as -s, -L, -k and --compressed are ignored.

cURL's implicit rules

With -d and no -X, cURL uses POST and Content-Type application/x-www-form-urlencoded. With -G, the data is appended to the URL as a query string. The converter mirrors these rules to generate equivalent code.

JSON bodies

When the body is valid JSON, the generated code represents it as a native structure: JSON.stringify of an object in JavaScript and json= with a dictionary in Python, making it easy to edit.

Frequently asked questions

Are multipart uploads (-F) supported?

Not yet. The converter warns when it finds -F so you can build the FormData manually.

Why does the Lua output use PerformHttpRequest?

The Lua target generates code for the CitizenFX runtime (FiveM/RedM), which provides PerformHttpRequest natively on the server.

Does my token appear in the generated code?

Yes, headers are copied literally. Conversion is local, but remember to move secrets into environment variables before committing.

Related tools