Developer tools · free · no signup

cURL to Code Converter

Convert cURL commands into JavaScript Fetch, Python Requests, Go, and PHP code. Your work stays on this device whenever possible.

Free to useNo accountClear results
Preparing tool…
Simple, transparent workflow

How to use cURL to Code Converter

  1. Paste a command into "Paste cURL Command"; backslash line continuations are joined, and the text must begin with curl. "Load Sample" inserts a POST with a Bearer header.
  2. Choose a "Target Language": JavaScript (Fetch API), JavaScript (Axios), Python (Requests), Python (http.client), Go (net/http), PHP (cURL), Node.js (https / fetch), Java, C#, Rust, Ruby, Swift, Kotlin, PowerShell or HTTPie.
  3. Press "Generate Code"; problems such as a missing URL appear in the status line instead of the output.
  4. Check that the generated code carries your method, headers and body, and that any -u login was turned into an Authorization header.
  5. Use "Copy Code" or "Download Code", which saves request.js, request.py, request.go or request.php.

Worked example

Paste curl -X POST https://api.example.com/items -H "Content-Type: application/json" -d '{"id":7}' and choose Python (Requests). The output declares url as "https://api.example.com/items", a headers dictionary containing Content-Type, payload = {"id":7}, and the call requests.post(url, headers=headers, json=payload). The status line confirms the conversion; nothing is sent to the address.

When to use this tool

  • Translating a command copied from API documentation into Go for a service.
  • Turning a DevTools-style curl call into a Fetch snippet for a front-end test.
  • Producing a PHP cURL block to drop into a legacy script.

Important limitations

Translates standard HTTP options, headers, cookies, and payloads into idiomatic code, plus a request breakdown, one-click secret redaction, and 8 additional target languages (Java, C#, Rust, Ruby, Swift, Kotlin, PowerShell, HTTPie).

Comparing alternatives

Other options for curl to code converter include curlconverter, Postman, Insomnia.

ToolkitPoint is not affiliated with those services.

Frequently asked questions

Which cURL options are understood?

-X and --request, -H and --header, the data flags -d, --data, --data-raw, --data-binary, --data-urlencode and --json, -u and --user, --url, -F/--form (multipart), -k/--insecure and -A/--user-agent (flagged in the request breakdown), and -b/--cookie. --compressed is still ignored. A value like the file after -o that appears before the URL may be mistaken for the URL.

How is the HTTP method chosen?

From -X when present. Without it the tool assumes POST if any data flag is used and GET otherwise. Multiple data flags are joined with an ampersand.

What becomes of -u username:password?

It is turned into an Authorization: Basic header by base64-encoding the pair, and the result sits in the generated code as easily reversible text. Swap it for an environment variable before committing the snippet.

Are cookies from -b carried across?

Yes. -b/--cookie is written into the generated code as a Cookie header, and the redaction toggle can swap its value for an environment variable like any other credential.

Is JSON turned into proper Python?

The Requests output pastes the body as a Python dict literal, so JSON true, false and null must be changed to True, False and None by hand. The Go and PHP outputs embed the body as an escaped string instead.