Convert curl to Python, JavaScript, Go, PHP and more — offline

5 min read
curl
api
http
code generation
Try cURL Command Parser & Code GeneratorFree, runs in your browser — no upload or sign-up.Open tool →

API docs and browser DevTools ("Copy as cURL") give you a curl command, but your app needs real code. The cURL Command Parser & Code Generator converts it in your browser — headers, cookies and API keys never leave your device.

How to use it

  • Paste the curl command (multi-line commands with \ are fine).
  • Pick a language from the list: JavaScript or TypeScript fetch, Axios, Node.js https, Python requests or httpx, Go net/http, PHP cURL or Guzzle, Java HttpClient, C# HttpClient, Rust reqwest or Dart http.
  • Copy the code. The breakdown below shows the method, query parameters, headers, cookies, form fields and body.

Flags it understands

  • -X / --request for the method, -H for headers and -b or a Cookie header for cookies.
  • -d, --data-raw, --data-binary, --data-urlencode and --json for request bodies. JSON bodies become native objects (for example json=payload in Python).
  • -F multipart fields, including @file uploads, turned into FormData, files= or multipart builders.
  • -u basic auth, -A user agent, -e referer, -G (data as query string), -I (HEAD) and --compressed.

Example

text
curl -X POST "https://api.example.com/users" -H "Content-Type: application/json" -d '{"name":"Ada"}'

becomes this in Python:

text
import requests

headers = {
    "Content-Type": "application/json",
}
payload = {
  "name": "Ada"
}

response = requests.request("POST", "https://api.example.com/users", headers=headers, json=payload)
response.raise_for_status()
print(response.text)

Tips

Remove short-lived session cookies before sharing generated code, and move API keys into environment variables. Shell variables like $TOKEN are copied literally, so replace them with your own values.

Tools from this article

← All articles