cURL is a free command-line tool that moves data between your computer and a server using a URL. Short for Client URL, it lets you download files, test APIs, send form data and check exactly what a server returns, all from a terminal, without opening a browser. If you have ever copied a cURL command from API documentation and wondered what it actually does, this guide answers that question in plain language, with commands you can run yourself.
By the end you will know how cURL works, which options matter most, how to test an API endpoint, how to download and resume files, and how to fix the errors beginners hit most often. The examples work the same on Windows, macOS and Linux, and you need no paid software to follow along.
What Is cURL and How Does It Work?
When you type a cURL command, the tool takes your URL and a set of instructions, then handles the whole network conversation for you. It resolves the domain name, opens a connection, applies the security settings for HTTPS, sends your request and prints or saves the response. Under the hood it uses the libcurl library, which is also embedded in countless apps, cars and devices, so learning the command-line tool teaches you a skill that transfers far beyond one terminal window.
By default cURL performs an HTTP GET request and displays the response body in your terminal. That is why a single short command can fetch an entire web page. Unlike a browser, cURL does not render pages, run JavaScript or store a visual history. That raw view is an advantage: you see exactly what a server returns, including status codes and headers when you ask for them. Developers value this honesty when debugging, because no cache or extension hides the real behaviour.
cURL also returns exit codes that scripts can check, which makes it reliable for health checks, cron jobs and continuous integration steps that must fail loudly when a service is down or a response changes unexpectedly. It supports HTTP, HTTPS, FTP, SFTP and several other protocols, so the same tool covers downloads, uploads, API calls and server checks.
What Does cURL Stand For?
The name cURL stands for Client URL, which describes the job precisely: it is a client that fetches or sends data at a URL you give it. The project has been maintained for decades and ships with macOS and most Linux distributions, while modern versions of Windows include it by default. Because it is free and open source, tutorials, API docs and deployment scripts all assume it is available, which is one reason you keep meeting it.
How a cURL Request Travels
A request moves through a short, predictable sequence. First cURL looks up the domain name, then it opens a connection to the server on the right port, usually 443 for HTTPS. It checks the server certificate, sends the request line, headers and any body data, then waits for the response. Finally it hands you the status code, the headers and the body, or saves them to a file if you asked. Verbose mode, covered later in this guide, prints each of these steps so you can see exactly where a slow or failing request gets stuck.
- Sends a basic GET request to any URL
- Supports HTTP, HTTPS, FTP, SFTP and more protocols
- Prints raw responses without rendering or scripts
- Returns exit codes that automation can rely on
- Runs the same way on Windows, macOS and Linux

Your First cURL Commands
The fastest way to learn cURL is to run it. Open your terminal, try each step below, and watch what comes back before moving on. Start simple and add one option at a time, so you always know which change caused a different result.
- Fetch a web page. Run
curl https://example.comand you will see the raw HTML of the page printed in your terminal. Nothing is saved and nothing is rendered. - Save the result to a file. Add
-o page.htmlto the same command and the HTML lands in a file called page.html instead of scrolling past on screen. - Check the headers only. Run
curl -I https://example.comto see the status code, server, content type and cache headers without downloading the body. - Follow a redirect. If a link bounces you to another address, add
-Land cURL will follow each redirect until it reaches the final page. - See the full exchange. Add
-vto print the connection steps, the request headers and the response headers, which is the quickest way to understand what went wrong when a request fails.
Two habits will save you time from day one. First, quote URLs that contain special characters, especially on Windows, so the shell does not misread question marks and ampersands. Second, keep a small notes file of working commands for your own projects. That file turns cURL from something you look up repeatedly into a fast, dependable part of your daily workflow.
Essential cURL Options You Will Use Most
Options are short flags that change how cURL behaves, and a small set covers most real work. The -X flag sets the request method such as POST, PUT or DELETE, while -H adds headers for content type, authorisation or custom values a server expects. Use -d to send data in the request body, -o to save output to a named file and -O to save using the remote file name. The -i flag includes response headers in the output, -v turns on verbose mode that shows the full connection exchange, and -L tells cURL to follow redirects, which is essential when testing shortened links or login flows.
Methods and Headers
Most API work needs a method and at least one header. A typical POST with JSON looks like this: curl -X POST -H "Content-Type: application/json" -d '{"name":"Mahi"}' https://api.example.com/users. The -X POST sets the method, the -H flag tells the server the body is JSON, and -d carries the data. For longer payloads, save the JSON in a file and reference it with -d @data.json, which keeps commands short and reusable.
Saving Output and Following Redirects
When you download a file, choose the name yourself with -o or let cURL use the server name with -O. If a download returns an HTML page instead of the file you expected, the cause is usually a redirect or a login wall. Adding -L to follow redirects, or inspecting headers with -I, quickly reveals where the request actually landed and whether extra authentication is required. If you manage a site of your own, the same habit helps when you fix an SSL certificate error on WordPress and need to confirm the secure version of a page actually loads.
-Xsets the HTTP method for the request-Hadds headers such as Authorization-dsends data in the request body-oand-Osave responses to files-ishows headers and-vshows full details-Lfollows redirects to the final page
Using cURL to Test APIs With Confidence
API testing is where cURL shines brightest. Most API documentation includes a cURL example for every endpoint because it is universal and easy to copy. To test an endpoint, send the request, then check three things: the HTTP status code, the response headers and the body. A 200 status with the expected JSON usually means success, while 401 points to a missing or expired token, 404 means the path is wrong, and 429 means you are sending requests too quickly. Adding the -w flag lets you print timing and status details in a clean format that is easy to log or compare across environments.
- Send a simple GET first. Confirm the endpoint responds at all before you add authentication or a body.
- Add your token in a header. Pass it as
-H "Authorization: Bearer YOUR_TOKEN"rather than in the URL, and never paste real production keys into shared documents or screenshots. - Check the status code. Use
-ior-w "%{http_code}"so you see the code instead of guessing from the body alone. - Read the body carefully. Error messages in JSON usually name the missing field or the expired scope, which tells you exactly what to fix.
- Repeat against staging and production. Testing both environments with the same saved command is a simple way to spot configuration differences before your users do.
When sending JSON, set the Content-Type header to application/json and keep the payload in a separate file for longer requests. If an endpoint accepts uploads or form fields, the -F flag sends multipart form data, which is the same mechanism browsers use for file upload forms. And if you are building something that calls AI services, our roundup of the best free AI tools is a good place to compare the APIs you might test with cURL next.
- Check status code, headers and body together
- Send tokens in headers, never in URLs
- Use
-wto log timing and status cleanly - Store long JSON payloads in separate files
- Compare staging and production with one command

Downloading Files and Handling Redirects
cURL is also a dependable downloader. For large files, the -C - option resumes an interrupted transfer instead of starting over, which matters on slow or unstable connections. Progress bars show speed and estimated time, and you can limit bandwidth with --limit-rate when a download should not saturate a shared connection. A typical resume command looks like curl -C - -O https://example.com/large-file.zip, which picks up where the partial file stopped.
Always verify important downloads. Many publishers provide a checksum, and comparing it after the transfer confirms the file arrived intact and untampered. Saving files with clear names and noting the source URL in your project records also prevents confusion later, especially when a script downloads the same asset repeatedly. These small disciplines turn quick one-off downloads into a repeatable process your whole team can trust and audit.
- Resume interrupted downloads with
-C - - Limit bandwidth on shared connections
- Follow redirects with
-Lwhen files fail - Verify checksums on important downloads
- Record source URLs for repeatable scripts
Common cURL Errors and How to Fix Them
Most cURL errors fall into a few familiar groups. Certificate problems produce messages about being unable to verify the server; the proper fix is updating your certificate store or using a correct bundle, not disabling verification permanently, because the -k flag removes an important safety check. Connection refused usually means the service is down or the port is wrong, while a timeout suggests a firewall, a slow server or an overloaded network. Name resolution failures point to DNS trouble or a mistyped domain, and garbled output often means the response was compressed or binary data was printed directly to the terminal instead of saved to a file.
Verbose mode is your best friend here. Running the same command with -v shows each step, so you can see exactly where the exchange breaks down. Read that output from the top, line by line, and a confusing failure turns into a specific, fixable cause. With a little practice you will diagnose most cURL problems in under a minute and know whether the fault lies with your command, your network or the remote server. If the site on the other end is your own WordPress install, knowing the basics of what web hosting is helps you tell a server-side problem from a mistake in your command.
- Fix certificate errors by updating the store
- Check ports and services on refused connections
- Use verbose mode to locate the failure point
- Save binary responses to files, not the terminal
- Avoid
-kin production for safety reasons

cURL vs Wget and Postman
Beginners often ask whether to learn cURL, wget or Postman, and the honest answer is that they overlap more than they compete. Wget is built mainly for downloading files and mirrors whole sites well, but it is less flexible for API testing because it has fewer options for custom methods, headers and request bodies. Postman gives you a friendly visual interface for building and saving API requests, which is great for exploring an unfamiliar API, but it needs a graphical app and an account for its cloud features. cURL sits in the middle: it runs anywhere, works in scripts and CI pipelines, and copies straight into documentation. Many developers explore an API in Postman, then keep the cURL export as the permanent, shareable version of the request.
Frequently Asked Questions
Is cURL free and safe to use?
Yes. cURL is free, open-source software released under a permissive licence, and it has been maintained for decades. Download it from the official site or your operating system package manager, keep it updated, and avoid disabling certificate verification so your connections stay protected.
What is the difference between cURL and a browser?
A browser renders pages visually, runs JavaScript and manages tabs and history. cURL simply sends requests and returns raw responses as text or files. That makes cURL faster for testing and automation, while a browser remains better for viewing and interacting with finished websites.
How do I send JSON data with cURL?
Set the method to POST with -X POST, add a header for Content-Type: application/json, and pass the JSON with the -d flag. For longer payloads, save the JSON in a file and reference it with the @ symbol so your command stays short and easy to reuse.
Does cURL work on Windows?
Yes. Modern versions of Windows include cURL by default, so you can run it from Command Prompt or PowerShell. Quote URLs carefully, since shells handle special characters differently, and use the same options you would on macOS or Linux for consistent results across systems.
How do I see the status code of a request?
Add -i to include response headers in the output, or use -w "%{http_code}\n" to print just the code. For debugging, -v shows the full exchange, including the request line and the certificate checks.
cURL earns its place in every technical toolbox because it is fast, scriptable and honest about what servers actually return. Start with simple GET requests, add headers and methods as your needs grow, and lean on verbose mode whenever something looks wrong. With the options, API techniques and fixes in this guide, you can test endpoints, download files and automate checks with confidence on any operating system you use.

