Run cURL Commands in Windows 11 (with Examples)

Published by Nyau Wai Hoe - Updated on

The cURL command, or “Client for URLs“, is a useful tool you can use to move data around on the internet, working with lots of different ways of communicating online like HTTP, HTTPS, FTP, and more. It’s very useful for users who work with networks and computers a lot.

If you’re using Windows 10 or Windows 11, you can use cURL directly in the Command Prompt; you don’t need to install anything else. This guide will show you how to use cURL on Windows 11 to do all sorts of things like downloading and uploading files, sending emails, dealing with cookies and HTTP headers, and handling SSL certificates.

Run cURL Commands in Windows 11 Examples

Checking if cURL is ready on Windows 11

First, we will make sure whether cURL already exists on your computer. Just open Command Prompt and type this:

curl --version

Verifying cURL Installation in Windows 11

This command will tell you which version of cURL you have. If the command doesn’t show anything but returns an error, it means your PC does not have cURL installed yet.

Also see: How to use FTP via Command Line (CMD) on Windows 11

How to download files with cURL

One of the first things people use cURL for is to download files from the internet. It’s pretty straightforward. To download a file, you just use the -O (or --remote-name) option with the file’s URL:

curl -O https://example.com/myfile.txt

This command pulls the file myfile.txt from example.com and puts it where you are right now on your computer.

Downloading Files with cURL in Windows CMD

If you want to save the file under a different name, just use the -o (or --output) option like this:

curl -o renamedfile.txt https://example.com/myfile.txt

With the -o option and a new filename, you can choose what the downloaded file is called.

Related resource: How to Download an FTP File Using CMD in Windows 11/10

Uploading files with cURL

cURL also lets you send (upload) files to a server using different methods like FTP. The following steps will show you how to do it with FTP:

curl -T localfile.txt ftp://example.com/ --user username:password

Uploading a File using cURL

This command line will upload localfile.txt from your computer to example.com. Just replace username:password with your login info for the FTP server.

Sending emails with cURL

You can also use cURL to send emails using the SMTP protocol, which is very good for automated emails. Below a quick example:

curl --url smtps://smtp.example.com --ssl-reqd --mail-from [email protected] --mail-rcpt [email protected] --upload-file email.txt --user username:password

In this case, email.txt is a file that has your email’s subject, headers, and body. Just swap in your details for the SMTP server and the email addresses.

Sending an Email with cURL in Windows 11

Handling cookies with cURL

When you need to work with cookies, cURL can also do that. You can send cookies with the -b (or --cookie) option, and save them with the -c (or --cookie-jar) option. Here’s how to send a cookie:

curl -b "name=value" https://example.com

And to save cookies from a server into a file, do this:

curl -c cookies.txt https://example.com

Managing Cookies with cURL command in Windows

Setting up HTTP headers with cURL

Sometimes you need to tell the server more about what you’re sending, and that’s where HTTP headers come in. With cURL, you can add these headers to your request like so:

curl -H "Content-Type: application/json" -H "Authorization: Bearer your_token" https://api.example.com

Setting HTTP Headers with cURL command in Windows 11

Checking SSL certificates

cURL can help you make sure SSL certificates are valid, which is important for secure web browsing. To check a certificate, you can use this:

curl -vI https://example.com 2>&1 | findstr "expire date"

This command gets the SSL certificate details from the server and looks for the expiration date, helping you ensure everything’s up to date and secure.

Linked issue: Fixing Website’s Security Certificate Error on Windows 11/10

Making POST requests with cURL

When you need to send data to a server, you might use a POST request. Doing this with cURL is easy. For example, if you want to send JSON data to an API, you could do it like this:

curl -d "{'key1':'value1', 'key2':'value2'}" -H "Content-Type: application/json" -X POST https://api.example.com

The -d option lets you specify the data you’re sending, and the -H option tells the server it’s in JSON format. The -X tells cURL this is a POST request.

cURL and REST APIs

cURL is also very useful for working with REST APIs, which use standard web methods like GET, POST, PUT, and DELETE. We’ve looked at GET (for downloading files) and POST (for sending data). Now for updating things, you’d use a PUT request like this:

curl -d "{'key1':'value1', 'key2':'value2'}" -H "Content-Type: application/json" -X PUT https://api.example.com/resource/1

And if you need to remove something, a DELETE request does the job:

curl -X DELETE https://api.example.com/resource/1

Some final thoughts

Using cURL from the Command Prompt in Windows 11 is not just easy; it’s a powerful way to talk directly with web services from your computer. Whether you’re automating tasks, testing servers, or doing a whole bunch of other web-related activities, cURL is a very useful tool that’s available across different platforms, making your work portable and widely usable.

If you ever get stuck with a cURL command or need a quick reminder on how to use it, just pop open the command line and type curl --help. Think of it as a mini-guide that’s always there when you need it, showing you all the commands and parameters you can use with curl.

Run cURL commands in Windows


Nyau Wai Hoe
Nyau Wai Hoe is the Founder and Chief Editor of WindowsDigitals.com. With a degree in software engineering and over 12 years of experience in the tech support industry, Nyau has established himself as an expert in the field, with a primary focus on the Microsoft Windows operating system. As a tech enthusiast, he loves exploring new technologies and leveraging them to solve real-life problems.

Share via
Copy link