My Tool Studio
Developer

cURL to Code Converter

This curl to code converter turns a curl command into code for 19 targets as you type: JavaScript fetch, axios and Node.js, Python requests, PHP cURL and Guzzle, Go, Java, C#, Ruby, Rust, Swift, Kotlin, Dart, PowerShell, HTTPie, wget, a raw HTTP request and a JSON summary. It reads the method, headers, body, basic auth, cookies, form uploads, query data, timeouts, proxies and the -k, -L and --compressed switches. JSON bodies come out as real objects where the language allows. Paste a command from API docs, Postman or the browser's Copy as cURL, bash or cmd style, then copy or download the code. Parsing happens in your browser, so tokens in the command are not sent anywhere.

Always freeNo sign upRuns in your browser

Paste from docs or from Chrome, Edge or Firefox DevTools (Copy as cURL, bash or cmd). Nothing is sent anywhere.

JavaScript fetch
const res = await fetch("https://api.example.com/users", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer abc123"
  },
  body: JSON.stringify({
    "name": "Ada Lovelace",
    "role": "admin",
    "active": true
  })
});
const data = await res.json();
console.log(res.status, data);
What the command does
Request
POST https://api.example.com/users
Headers
Content-Type, Authorization
Body
52 bytes

How to use

01

Paste a curl command

Paste the command into the box, or press an example. Backslash and caret line breaks, single and double quotes, and the $'...' strings from Chrome's Copy as cURL are all understood.

02

Pick a language

Press one of the popular languages, or choose any of the 19 targets from the menu. The code updates as you edit the command. What the command does summarizes the parsed method, URL, headers and options.

03

Copy or download the code

Press Copy or Download. Replace placeholders such as fileInput for form uploads, and move secrets like bearer tokens into environment variables before you commit anything.

Why cURL to Code Converter

Supported curl flags

The converter covers the flags that change what is sent. Anything else is ignored, so check the generated code if your command depends on an option that is not listed here.

FlagMeaning in curlIn the generated code
-X, --requestSet the HTTP methodmethod: "PUT" or requests.request("PUT", ...)
-H, --headerAdd a request headerEntry in the headers object or dictionary
-d, --data, --data-raw, --data-binarySend a request body, joined with & if repeatedbody, data, json= in Python, or the body option in each language
--data-urlencodeURL-encode the value before sendingEncoded text added to the body
--jsonSend JSON with JSON Content-Type and Accept headersBoth headers plus a JSON body
-F, --formMultipart form field or file uploadFormData, or data= and files= in Python
-u, --userBasic authenticationAuthorization header, auth option in axios, auth= in Python
-b, --cookieSend cookiesCookie header
-A, -eUser-Agent and RefererMatching headers
-G, --getPut the data in the query stringData appended to the URL
-I, --headSend a HEAD requestmethod: "HEAD"
-k, --insecureSkip TLS certificate checksverify=False in Python, a comment in JavaScript
-L, --locationFollow redirectsRedirect option where the library needs one
-m, --max-timeGive up after N secondsTimeout setting in each language
-x, --proxySend through a proxyProxy setting, or a comment
--compressedAsk for and decode gzipDecompression option in PHP, C# and wget; automatic elsewhere

Output targets

Each target writes idiomatic code for its library. Pick the one your project already uses, so no new dependency is needed.

GroupTargets
JavaScriptfetch (browser), axios, Node.js fetch
Pythonrequests
PHPcURL extension, Guzzle
Other languagesGo net/http, Java HttpClient, C# HttpClient, Ruby Net::HTTP, Rust reqwest, Swift URLSession, Kotlin OkHttp, Dart http
Command linePowerShell Invoke-WebRequest, HTTPie, wget
Other formatsRaw HTTP request, JSON request details

Common questions

Which curl flags does the curl to code converter support?
It handles -X, -H, -d, --data, --data-raw, --data-binary, --data-urlencode, --json, -F, --form-string, -u, -b, -A, -e, -G, -I, -k, -L, -m or --max-time, -x or --proxy, --compressed and --url. Flags that do not change the request, such as -s, -v and -i, are ignored, and flags that take a value without affecting the request, such as -o, are skipped with their value.
How do I copy a request as cURL from Chrome DevTools?
Open DevTools, go to the Network panel, right-click the request, then choose Copy and Copy as cURL. Both the bash and the cmd versions work here; the converter removes the caret escapes that the Windows cmd version adds. DevTools includes every header the browser sent, so delete cookies and sec-fetch headers you do not need.
Why did my converted curl request switch from GET to POST?
That matches curl: sending data with -d, --json or -F implies POST unless you set another method with -X. With -G, the data is added to the URL as a query string and the method stays GET.
Why does the Python code use json= instead of data=?
When the Content-Type header says JSON and the body parses as JSON, the tool passes it as json=payload so requests serializes it for you. Any other body is passed as data= exactly as written in the command.
What happens to a curl command without http:// or https://?
The converter adds http:// in front, which is what curl does by default. Change it to https:// in the code if the server expects a secure connection.
How are file uploads with -F converted to code?
Text fields are appended to a FormData object in fetch and axios, or put in a data dictionary in Python. A field like avatar=@photo.jpg becomes fileInput.files[0] in JavaScript, which you replace with your own file object, and open("photo.jpg", "rb") in Python's files= argument.
Why did the fetch code add a Content-Type header I did not write?
curl sends -d data as application/x-www-form-urlencoded unless you set a Content-Type. The fetch API would label a plain string body as text/plain, so the converter adds the form header to keep the request identical.
Does the curl converter handle -k or --insecure?
Yes, in the way each language allows: verify=False in Python, InsecureSkipVerify in Go, a certificate callback in C#, danger_accept_invalid_certs in Rust, CURLOPT_SSL_VERIFYPEER in PHP, -SkipCertificateCheck in PowerShell and --verify=no in HTTPie. Where a language has no simple switch, such as fetch, a comment explains the option. Only skip certificate checks for local testing.
Can the curl converter write PHP, Go or Node.js code?
Yes. PHP comes in two styles, the cURL extension and Guzzle. Go uses net/http, and Node.js uses the built-in fetch, with openAsBlob for file uploads. Java, C#, Ruby, Rust, Swift, Kotlin, Dart and PowerShell are in the language menu too.
Is the curl command sent to a server during conversion?
No. Parsing and code generation run as JavaScript in your browser tab. That matters because copied commands often contain live API keys and session cookies.

More Developer tools

View all