cURL Converter

Convert cURL commands into code for JavaScript, Node axios, Python, PHP, Go, Rust, Java, C#, PowerShell and Ruby, with headers, auth, cookies and body.

About this tool

A cURL converter for the command you copied from a browser Network tab or an API reference: paste it and get working code for JavaScript (fetch), Node.js (axios), Python (requests), PHP (cURL), Go, Rust, Java, C#, PowerShell or Ruby, with headers, authentication, cookies and the request body carried over. People often search for a curl converter or curlconverter to avoid rewriting the request by hand; this one runs in your browser, so keys and tokens inside the command are not sent anywhere, and anything it cannot convert is listed under the output instead of being dropped silently.

How to use it

  1. Paste a full cURL command into the input box (a copy from the browser Network tab, "Copy as cURL", works).
  2. Pick a language: JavaScript, Node axios, Python, PHP, Go, Rust, Java, C#, PowerShell or Ruby. The tool remembers your choice.
  3. Read the notes under the output for any flag that was not converted, then copy the code and run it as the line under the tabs describes.

FAQ

What cURL flags are supported?

The method (-X, -I), URL (also --url), headers (-H), the body (-d, --data, --data-raw, --data-binary, --data-urlencode, --json, and -G to move it into the query string), basic auth (-u), cookies (-b "name=value"), -A and -e for User-Agent and Referer, -L for redirects, -k for insecure TLS and --compressed. Combined short flags such as -sSL and attached values such as -XPOST also work. Flags that only change logging or output, like -s and -v, are ignored.

What happens to flags the converter does not understand?

They are listed in a note under the output, for example "Not converted: -F, -o", so you know what to add by hand. The most common ones are -F multipart forms, -o and -O for saving files, -T uploads, proxies (-x), client certificates (--cert) and reading data or cookies from a file (-d @file, -b cookies.txt).

How are -u, -b and -A mapped in each language?

Basic auth uses the language's own support where it has one: SetBasicAuth in Go, basic_auth in reqwest, the auth option in axios, basic_auth in Ruby, and an Authorization: Basic header built with Base64 in Java, C#, PowerShell, JavaScript, Python and PHP. Cookies from -b are sent as a Cookie header, and -A and -e become User-Agent and Referer headers (PowerShell uses -UserAgent).

Why does the code add a Content-Type when my command did not have one?

cURL sends Content-Type: application/x-www-form-urlencoded for a -d body when you do not set one, and the Go, Rust, Java, C#, Ruby and axios output does the same so the request matches what cURL would send. The original JavaScript, Python and PHP output is unchanged, so add the header yourself in those if the server needs it.

Does it follow redirects and decompress responses like cURL?

Only when you pass -L and --compressed, and only where the language does not already do it. Go, Rust, C#, PowerShell, axios, fetch and requests follow redirects by default; Java and Ruby do not, so -L turns on redirect following there. --compressed adds gzip handling for Java, C# and Rust, and the other languages decompress automatically.

How do I run the generated code?

The line under the language tabs says how. In short: Node needs npm install axios, Python needs pip install requests, Go runs with go run, Java 11 or later runs with java Main.java, C# needs .NET 6 or later (top-level statements), Rust needs the reqwest line added to Cargo.toml, PowerShell runs with pwsh, and Ruby only needs the standard library.

Is the cURL command sent to a server to parse?

No. Parsing and code generation both happen in your browser, which matters because cURL commands copied from devtools often contain real API keys, tokens or session cookies.

Why does the method default to POST sometimes?

If a cURL command includes a -d/--data flag but no explicit -X, cURL itself defaults to a POST request, and the tool mirrors that behavior (unless you also pass -G or -I).

Is this the same as curlconverter.com?

It does the same kind of job, converting a cURL command into code, but it is a separate and smaller tool. It covers ten languages and the common flags. curlconverter.com supports more languages and more flags, so if you need a language that is not listed here, or flags such as multipart uploads, use a larger converter.

Related tools

Guides & comparisons

← All tools · Web & API · Blog · Cheat sheets · FAQ