Skip to content

Convert a cURL command into fetch, axios, Go net/http, Python requests or PHP cURL code.

Loading tool

About cURL to Code

Converts a cURL command into equivalent code for JavaScript fetch, axios, Go net/http, Python requests or PHP cURL. It understands common options such as -X, -H, -d/--data-raw/--json, --data-urlencode, -F form fields, -u basic auth, -b cookies, -A, -G, -k, -L, --compressed and timeouts, and shows the parsed method, URL, headers and body. Options it cannot translate, such as proxies or data read from files, are listed as notes instead of being silently dropped.

Common uses

  • Turn a 'Copy as cURL' request from browser DevTools into code
  • Port an API example from documentation to your language
  • Check exactly which headers and body a cURL command sends
  • Convert a multipart file upload command into a script

FAQ

How do I copy a request as cURL from the browser?
In Chrome, Edge or Firefox DevTools, open the Network tab, right-click a request and choose Copy > Copy as cURL. On Windows, pick the bash version if offered.
Which HTTP method does curl use when -X is not given?
curl uses GET by default and switches to POST when data is sent with -d, --data-raw, --json or -F. With -G, the data is appended to the URL as a query string and GET is used.
Does it handle multi-line commands?
Yes. Commands split over several lines with backslash continuations, as DevTools produces them, are parsed normally.