DevToolPal
EN

curl to Code Converter

Convert a curl command into JavaScript fetch, Node.js axios, Python requests, Go, PHP, Java or C# code.

Runs locally, never uploaded

Options

curl command

0 chars · 0 B

Code

0 chars · 0 B

What this tool does

The curl to Code Converter turns a curl command into ready-to-run code for seven targets: JavaScript fetch, Node.js axios, Python requests, Go net/http, PHP cURL, Java HttpClient and C# HttpClient. API docs, Postman and browser DevTools all hand out requests as curl commands; this tool saves you from rewriting the method, URL, headers, body and authentication by hand.

The parser is written specifically for curl’s command line. It reads shell quoting the way bash does, understands bundled short options like -sSL and attached values like -XPOST, and keeps the order of your headers.

How to use it

  1. Paste a curl command into the input, or press Sample to try one.
  2. Choose the Language you want.
  3. Copy the result or download it as a source file.

A request body sent with -d becomes a form-encoded body, --json (or a JSON Content-Type) becomes a JSON body that is pretty-printed where the language allows it, and -F fields become a multipart form with file uploads. -u user:password is turned into the language’s own basic-auth option, and -k, -L, -m and -x map to TLS verification, redirects, timeouts and proxies.

Example

This command posts JSON with a bearer token:

curl https://api.example.com/v1/users \
  -H 'Authorization: Bearer TOKEN' \
  --json '{"name":"Ada"}'

For Python it becomes a requests.post() call with a headers dict and json=json_data; for Go it becomes an http.NewRequest with the headers set one by one and the body as a string reader.

Tips

  • If the converter reports an error, the message names the problem and the cursor jumps to the offending token, such as an unknown option or an unterminated quote.
  • Pipes and redirects after the command (| jq ., > out.json) are ignored.
  • Generated code reads files you reference with @file at run time, so keep those paths valid relative to where the program runs.
  • Review secrets before sharing a link: the share button includes the command in the link’s hash.

FAQ

› Is my curl command sent to a server?

No. The command is parsed and converted entirely in your browser, so tokens, cookies and passwords in it never leave your device.

› Which curl options are supported?

The ones that shape the request: -X, -H, -d, --data-raw, --data-binary, --data-urlencode, --json, -F, -u, -b, -A, -e, -G, -I, -L, -k, -m, -x, --compressed and --url. Options that only affect curl's own output, such as -s, -v, -o or -w, are accepted and ignored.

› Can I paste a command from the browser's DevTools?

Yes. Use Copy as cURL (bash) in the Network panel. Line continuations with \, ^ (Windows cmd) and ` (PowerShell) are all understood, as are single, double and $'…' quotes.

› What happens with options the code cannot reproduce?

The generated code starts with a Note comment, for example when -k cannot be expressed with fetch or when curl would read a file the code does not open. Unknown options are reported as an error pointing at the exact option.