Skip to content

cURL to Code

Convert a curl command into ready-to-run code for JavaScript fetch, axios, Node.js https, Python requests, Go net/http, PHP cURL or Rust reqwest. The tool parses the command like a shell does, including quotes, line continuations and the $'...' strings browsers use for Copy as cURL, then rebuilds the method, URL, headers, body and authentication in the language you choose.

Reset

Frequently asked questions

Which curl options are converted?

The request method (-X), headers (-H), request bodies (-d, --data-raw, --data-binary, --data-urlencode and --json), basic authentication (-u), the user agent (-A), the referer (-e), cookies (-b with name=value pairs), bearer tokens (--oauth2-bearer), -G, -I, -L and -k. Options that only affect curl's own output, such as -s, -v and -o, and --compressed, whose decompression the libraries handle themselves, are left out without a note. Any other option is listed in a comment at the top of the code so you can add it by hand.

What happens with a JSON body?

When the Content-Type header names JSON and the body parses as a JSON object or array, the fetch and axios code pass it as an object and the Python code uses requests' json argument with a Python dictionary. The other languages send the body exactly as written in the command.

Does it support file uploads and multipart forms?

No. Bodies read from a file with @, -F form fields and -T uploads are rejected with a message, because the file contents are not part of the command. Paste the body inline with --data-raw or add the upload to the generated code yourself.

How is -u user:password converted?

The credentials are encoded into an Authorization: Basic header, which is exactly what curl sends. If the command already sets an Authorization header, that header is kept and -u is ignored, as curl does.

What about redirects and certificate checks?

curl follows redirects only with -L, while fetch, axios, Python requests, Go and reqwest follow them by default; the PHP code adds CURLOPT_FOLLOWLOCATION when -L is present. With -k the Node.js, Python, Go, PHP and Rust code turn off certificate checks; fetch and axios have no portable switch for it, so -k is listed as not converted there.

Do I need extra packages to run the code?

fetch, Node.js https, Go net/http and PHP cURL are built in. The axios code needs the axios package, the Python code needs requests, and the Rust code needs the reqwest crate and tokio for its async main function.

About OneClick Pro

OneClick Pro is a free collection of more than 150 web tools for everyday work: converting images and units, formatting and validating code, checking domains and SEO, and working with text, dates and numbers. Every tool runs without registration or subscription, and what you enter is only used to calculate your result and is never stored. Use it as a quick toolbox for one-off tasks, or bookmark the tools you rely on every day.