How to install cURL on windows and how to use it

What is cURL?

cURL is a free, versatile command-line tool used for transferring data with URL syntax, supporting protocols like HTTP, HTTPS, FTP, and more. It is commonly used by developers and system administrators for tasks such as downloading files, making API calls, and testing web services.

While macOS and Linux include cURL by default, Windows users are left to install it manually. Although PowerShell offers cmdlets like Invoke-WebRequest that mimic some of cURL’s functionality, users accustomed to Unix tools may find themselves asking: Where is cURL on Windows?

This guide will walk you through five different ways to install cURL on Windows and provide examples to help you start using it.


Table of Contents

  1. Why Install cURL on Windows?
  2. How to Install cURL on Windows
  3. How to Use cURL on Windows
  4. Practical Examples of cURL Commands
  5. Troubleshooting Common Issues
  6. Summary and Next Steps

Why Install cURL on Windows?

Installing cURL on Windows opens up a world of powerful command-line operations. It allows you to:

  • Automate file transfers.
  • Test RESTful APIs.
  • Fetch web content and headers.
  • Perform advanced network diagnostics.

Windows users can leverage cURL to bridge the gap between Windows and Unix environments, enabling seamless compatibility with cross-platform scripts and workflows.


How to Install cURL on Windows

1. Install cURL using Chocolatey

Chocolatey is a popular Windows package manager that simplifies software installation.

  1. First, install Chocolatey by following the instructions here.
  2. Once installed, open a PowerShell or Command Prompt as Administrator and run the following:
choco install curl -y

Chocolatey will handle the installation for you, and cURL will be ready to use.


2. Downloading Pre-Compiled Binaries

For users who prefer manual installation, pre-compiled cURL binaries are available.

  1. Visit cURL’s downloads page.
  2. Scroll down to the Windows section and download the appropriate binary (e.g., Win64 – Generic).
  3. Extract the ZIP file and navigate to the src folder to find curl.exe.
  4. Copy curl.exe to a directory in your system’s PATH, such as C:\Windows\System32.

You can now access cURL from any command line.


3. Compiling cURL from Source Code on windows

Compiling cURL from source is an advanced method, ideal for users who need the latest version or want a hands-on learning experience.

  1. Download the source code from cURL’s GitHub repository.
  2. Follow the build instructions provided in the official documentation.

This method requires tools like Visual Studio or MinGW for compilation and is recommended only for advanced users.


4. Using CYGWIN

CYGWIN is a Unix-like environment for Windows that includes many precompiled Unix utilities.

  1. Download the CYGWIN installer from here.
  2. During installation, select the cURL package from the list of available tools.
  3. Complete the installation, then launch the CYGWIN terminal to use cURL.

CYGWIN provides a Unix-like experience on Windows, but it is limited to the tools included in its ecosystem.


5. Install curl on Windows Subsystem for Linux (WSL)

WSL offers a full Linux environment on Windows, complete with native tools like cURL.

Enable WSL as a Windows feature:

  • Open PowerShell as Administrator and run:
wsl --install

WSL provides a comprehensive Linux environment but requires additional setup compared to other methods.

Install WSL without the Microsoft store

If you are unable to or don’t want to use the Microsoft store, you can also download distributions from here:

Once the distribution has been downloaded, navigate to the folder containing the download and run the following command in that directory, where app-name is the name of the Linux distribution .appx file.

Add-AppxPackage .\app_name.appx

Once the Appx package has finished downloading, you can start running the new distribution by double-clicking the appx file. (The command wsl -l will not show that the distribution is installed until this step is complete).


How to Use cURL on Windows

Once installed, launch the appropriate command-line tool (Command Prompt, PowerShell, CYGWIN, or WSL). To confirm cURL is working, run:

curl --help

This will display a list of available commands and arguments.

Practical Examples of cURL Commands

1. Downloading Files

Download a file using the -O option:

curl -O https://example.com/file.zip

2. Fetching Webpage Headers

Inspect a webpage’s HTTP headers:

  • Linux/WSL/CYGWIN:bashCopy codecurl -s -D - http://example.com -o /dev/null
  • Windows PowerShell:bashCopy codecurl -s -D - http://example.com -o $null

Linux/WSL/CYGWIN:

curl -s -D - http://example.com -o /dev/null


Windows PowerShell:

curl -s -D - http://example.com -o $null

3. Making POST Requests

Post data to a server:

curl -d "key1=value1&key2=value2" -X POST http://localhost

Post a JSON file:

curl -d "@data.json" -H "Content-Type: application/json" -X POST http://localhost

Authenticate with basic credentials:

curl -u username:password http://localhost

Troubleshooting Common Issues with cURL on windows

  • Command Not Found: Ensure curl.exe is in a directory listed in your PATH.
  • SSL Certificate Errors: Use the -k option to bypass SSL checks (not recommended for production).
  • Installation Fails with Chocolatey: Run the command as an Administrator.

Summary and Next Steps

This guide covered five ways to install cURL on Windows and provided practical examples to help you get started. Whether you use Chocolatey for simplicity, WSL for a full Linux experience, or another method, cURL is an indispensable tool for developers and IT professionals.

For more advanced use cases, check out the free book Everything cURL and the official documentation.

Have questions or tips? Share them in the comments or explore our other tutorials for mastering command-line tools!