How to use curl on Windows (2023)

Curl (client URL) is a command-line tool powered by the libcurl library to transfer data to and from the server using various protocols, such as HTTP, HTTPS, FTP, FTPS, IMAP, IMAPS, POP3, POP3S, SMTP, and SMTPS. It is highly popular for automation and scripts due to its wide range of features and protocol support. In this article, you will learn how to use curl in Windows with various examples. Let’s get started.


  1. Install curl on Windows
  2. Curl syntax
  3. HTTP GET request
  4. Get remote file information.
  5. Download a file
  6. Resume interrupted download
  7. Authentication with Curl
  8. Upload a file
  9. Quote a command
  10. Change the user-agent
  11. Send a cookie
  12. Use a proxy server
  13. Additional request headers
  14. Send an email
  • Author
  • Recent Posts

Surender Kumar

Surender Kumar has more than twelve years of experience in server and network administration. His fields of interest are Windows Servers, Active Directory, PowerShell, web servers, networking, Linux, virtualization, and penetration testing. He loves writing for his blog.

Latest posts by Surender Kumar (see all)

  • ConfigMap in Kubernetes - Wed, Aug 2 2023
  • Node selector and node affinity in Kubernetes - Thu, Jul 27 2023
  • Upgrade Proxmox VE 7 to 8 - Fri, Jul 14 2023

Install curl on Windows

All the modern Windows versions, starting with Windows 10 (version 1803) and Server 2019, have the curl executable pre-installed, so there is no need for a manual installation. To determine the curl location and version in your system, you can use the following commands:

where curlcurl --version

Determine the location and version of curl in Windows

The curl --version command also lists the protocols and features supported by the current curl version. If you see an output, as shown in the screenshot above, you’re all set to use the built-in curl utility. If you get an error message instead, curl might not be available, probably because you’re on an earlier version of Windows (e.g., Windows 8.1 or Server 2016). In that case, you might need to manually setup curl in Windows.

Curl syntax

The curl command uses the following syntax:

curl [options...] [url]

It supports various options, which we will discuss later in this post. As with any other command-line tool, you can use the curl --help command to get help.

Getting help with the curl command

To get detailed help, you can use curl --help all. The help section is divided into categories, so the curl --help category gets you an overview of all the categories.

Now that you’ve become familiar with curl syntax, let’s discuss various use cases with the help of examples.

HTTP GET request

When you use curl against a URL without specifying any option, the request defaults to the GET method of the HTTP protocol. Try this:


The above command is essentially equivalent to curl --request GET, which sends a GET request to using the HTTPS protocol. To specify the HTTP protocol version (e.g., http/2), use the --http2 option, as shown below:

curl --http2

For URLs starting with HTTPS, curl first tries to negotiate to establish a http/2 connection and automatically falls back to http/1.1 if the negotiation fails. It also supports other methods, such as HEAD, POST, PUT, and DELETE. To use these methods, along with the curl command, use the --request (or -X) option, followed by the method. Notice that the methods that are available depend on the protocol being used.

Get remote file information.

As an admin, you might want to be interested in HTTP headers only. This can be done using the --head (or -I) option. Sometimes, a URL might redirect you to another location. In that case, --location (or -L) allows the curl to follow the redirects. You can also use --insecure (or -k) to allow insecure connections to avoid any TLS certificate errors if the target URL is using a self-signed certificate. Use this only when absolutely necessary. All three of these options can be combined in short-notation, as shown in the following command:

curl -kIL

View request headers allow insecure connection and follow redirect options with curl

You can see that short-notation is particularly useful for combining multiple options. The above command is essentially equivalent to the curl --insecure --head --location command.

The --head (or -I) option also gives you basic information about a remote file without actually downloading it. As shown in the screenshot below, when you use curl with a remote file URL, it displays various headers to give you information about the remote file.

curl -IL

Use curl to view the basic information about remote files

The Content-Length header indicates the size of the file (in bytes), Content-Type reveals the media type of the file (for instance image/png, text/htm), Server indicates the type of server application (Apache, Gunicron, etc.), Last-Modified shows the date when file was last changed on the server, and the Accept-Ranges header indicates the support of partial requests from the client for downloads, which essentially means you can resume an interrupted download.

Download a file

You can use curl with the --remote-name option (or -O, in short) to download a file and save it with the same name as on the server. The following command downloads the latest version of curl for Windows from the official website:

curl -OL

Downloading a file with a default name and progress indicator using curl

The -L option is added to follow redirects, if needed, for locating the resource. If you want to save the file with a new name, use the --output (or -o) option instead. Furthermore, while using the curl command in a script, you might want to suppress the progress indicator using --silent (or -s). Both options can be combined, as shown in the following command:

curl -sLo

Silently download a file and save with a custom name using curl

Resume interrupted download

The presence of Accept-Ranges: bytes in the response header literally means that the server supports resumable downloads. To resume an interrupted download, you can use --continue-at (or -C), which accepts an offset (in bytes). Generally, specifying an offset is tricky, so curl offers an easy way of resuming an interrupted download:

curl -OLC - 

Resuming an interrupted download with curl

As you can see in the screenshot, I was downloading an Ubuntu iso file, which was interrupted. When I ran the curl command again with the -C option, the transfer was resumed from the byte range where it was interrupted. The minus sign (-) next to -C allows the curl to automatically figure out how and where to resume the interrupted download.

Authentication with Curl

Curl also supports authentication, allowing you to download a protected file by supplying credentials with the --user (or -u) option, which accepts a username and password in the username:password format. If you skip typing the password, curl will prompt you to type it in no-echo mode.

curl -u surender -OL

Downloading a file using username and password authentication with curl

If you use a basic authentication method, you have to transfer a username and password, which means that you should use a secure protocol such as HTTPS (instead of HTTP) or FTPS (instead of FTP). If, for some reason, you have to use an unencrypted protocol, make sure you use an authentication method that doesn’t transmit credentials in clear text (for instance, Digest, NTLM, or Negotiate authentication).

Curl also supports the use of .curlrc, _curlrc, and .netrc config files, allowing you to define various curl options in a file and then to include the file in your command with curl --config (or curl -K), which is particularly useful for scripting.

Upload a file

The --upload-file (or -T) option allows you to upload a local file to a remote server. The following command shows how to upload a file from a local system to a remote web server using the FTPS protocol:

curl -kT C:\Users\Surender\Downloads\ -u testlab\surender ftps://

Uploading a file to a remote server using curl

The -k option is included to avoid certificate errors if the web server uses a self-signed certificate. The trailing slash at the end of the URL tells curl that the destination is a directory. You could specify multiple file names, such as “{,}.” The following command shows how to upload multiple files with a single curl command:

curl -kT sample[1-5].zip -u testlab\surender ftps://

Upload multiple files to a remote server using curl

Quote a command

As already discussed, curl supports various methods based on the underlying protocol being used. You can send additional commands using --quote (or -Q) to perform a particular operation either before or after the regular curl operation; for instance, if you want to download a file from a remote server using the FTPS protocol and want the file to be removed from the server once it has been downloaded successfully. To do this, you can run the command shown below:

curl -u testlab\surender -kO "ftps://" -Q "-DELE"

Delete a file after successful download using curl command

Here, I downloaded the file from an FTPS server with the help of the -O option. After the -Q option, I added a minus sign (-) just before the DELE command, which tells the curl to send the DELE command immediately after the file is downloaded successfully. Likewise, if you want to send a command to the server before performing the actual curl operation, use a plus (+) sign instead of a minus sign.

Change the user-agent

The user-agent tells a server what type of client is sending the request. When you send a curl request to the server, the curl/<version> user-agent is used by default. If the server is configured to block the curl requests, you can specify a custom user-agent using --user-agent (or -A). The following command sends a common Google Chrome user-agent:

curl -kIA "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/"

Use a custom user agent with a curl command to avoid server blocks

The above screenshot shows that a normal curl request was forbidden by the web server (with a 403 Forbidden response), but when I passed a custom user-agent, the request was successful, returning a 200 OK response.

Send a cookie

By default, the curl request does not send or store cookies. To write a cookie, use the --cookie-jar (or -c) option, and with --cookie (or -b), you can send a cookie:

curl -c /path/cookie_file -b /path/cookie_file

The first command writes a cookie file, and the second command sends the cookie with a curl request. You can also send a cookie in 'name = value’' format, as shown below:

curl -b 'session=abcxyz' -b 'loggedin=true'

Send multiple cookies using a curl command

I used the website to view HTTP request headers that aren’t normally visible to clients sending a request. If you don’t want to use this website, you could use the –verbose (or -v) option to see your request in raw form (which will show request headers, too).

Use a proxy server

Do you use a proxy server to connect to the internet? No problem! Curl lets you specify a proxy server using the --proxy (or -x) option. If your proxy server requires authentication, add --proxy-user (or -U):

curl -x -U username:password

The proxy server is specified in the server:port format, and the proxy user is specified in the username:password format. Again, you could skip typing the password for the proxy user, and curl will prompt you to enter it in no-echo mode.

Use a proxy server and authentication with a curl command

Additional request headers

Sometimes, you might want to send additional information along with your request to the server. With curl, you can do so easily by using --header (or -H), as shown in the following command:

curl -vkIH "x-client-os: Windows 11 Enterprise (x64)"

Specify additional headers with a curl request

You could send any information that isn’t available with standard HTTP request headers. In this example, I sent my operating system name. I also added the -v option this time to enable verbose output, which displayed the additional header being sent along with my curl request.

Send an email

Since curl supports the SMTP protocol, you could use it to send an email message. The following command shows how to send an email using curl:

curl --insecure --ssl-reqd smtps:// –-mail-from –-mail-rcpt --user --upload-file email_msg.txt

Send an email message using a curl command

Let’s quickly discuss the options used:

  • The --insecure (or -k) command is used to avoid an SSL certificate error. We have used this before.
  • The --ssl-reql option is used to upgrade a plain-text connection to encrypted connection if supported by the SMTP server. Alternatively, if you’re sure your SMTP server supports SSL, you could directly use the smtps server name (e.g., smtps://, as you can see in the screenshot.
  • The --mail-from option is used to define the sender’s (from) email address.
  • The mail-rcpt option specifies the recipient's email address.
  • The --user (or -u) option sends the username for authentication, which should match the mail-from address, because otherwise your message might be rejected or flagged as spam.
  • The --upload-file (or -T) option is used to specify a file that contains the email message to send.

The following screenshot shows the email message I received in my inbox:

Viewing the email message sent with curl

Viewing the email message sent with curl

Subscribe to 4sysops newsletter!

These are just a few examples, but there is a lot more you can do with curl. I highly recommend checking out curl help and experimenting with it. You'll notice what a powerful command curl is.

Want to write for 4sysops? We are looking for new authors.

4sysops members can earn and read without ads!

Top Articles
Latest Posts
Article information

Author: Edmund Hettinger DC

Last Updated: 25/07/2023

Views: 6341

Rating: 4.8 / 5 (78 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Edmund Hettinger DC

Birthday: 1994-08-17

Address: 2033 Gerhold Pine, Port Jocelyn, VA 12101-5654

Phone: +8524399971620

Job: Central Manufacturing Supervisor

Hobby: Jogging, Metalworking, Tai chi, Shopping, Puzzles, Rock climbing, Crocheting

Introduction: My name is Edmund Hettinger DC, I am a adventurous, colorful, gifted, determined, precious, open, colorful person who loves writing and wants to share my knowledge and understanding with you.