cURL to Code

Paste a curl command and get equivalent code for JavaScript fetch, Node https, Python requests or PHP cURL. Headers, body, basic auth and common flags are translated.

Use the tool

Why this tool exists

API documentation almost always shows examples as curl commands. To use the call in an application you have to rewrite it in your language, translating headers, quoting the body and handling auth by hand. That is where typos and missing headers creep in.

Paste the command, pick a target language and get working code. The parser understands common options such as -X, -H, -d and --data-raw, --json, -F forms, -u, -A, -b, -L and -k, and handles single and double quoted arguments and backslash line continuations. JSON bodies are turned into readable objects where possible. It does not execute anything, and the command is parsed in your browser, so tokens in the example are not sent anywhere. Review the code before use.

How to use it

  1. Paste your curl command, including backslash line breaks if present.
  2. Choose a target: fetch, node https, python requests or php cURL.
  3. Read the generated code in the output.
  4. Copy it into your project and replace any placeholder token.

Frequently asked questions

Which curl options are understood?

Method, headers, data and JSON bodies, form fields, basic auth, user agent, referer, cookies, redirects, insecure mode, compression and head or get requests. Unknown options are skipped rather than translated.

Does the tool send the request?

No. It only converts text into code. The command is never run, and nothing is sent to the API or to any server.

How is a JSON body handled?

If the Content-Type header mentions JSON and the body parses, it is written as a readable object that is serialised in the generated code. Otherwise the body is passed as a plain string.

Can I convert to other languages?

This tool covers four targets. For Go, Rust, Postman, HAR and others, see the related converters listed below the tool.