Skip to main content

Command Palette

Search for a command to run...

cURL Explained: Talk to the Internet from Your Terminal

Updated
4 min read
cURL Explained: Talk to the Internet from Your Terminal
S
Full-stack developer obsessed with performance, scalability, and clean systems. I use Arch btw.

Introduction

When you send a request to a server using cURL, the server doesn’t just send back data blindly. It returns a structured response that tells you what happened, what kind of data you got, and the actual content itself. Understanding this response format is essential for debugging APIs and backend systems. Once you can read a response properly, you can quickly figure out why something works or fails.


What is cURL?

cURL, which stands for “Client URL”, is a command line tool that lets you send and receive data over the internet. If your browser is a friendly graphical app that loads websites when you click links, cURL is the raw, text-based version of that idea. Instead of clicking buttons, you type commands in your terminal to make requests to servers and see their responses directly.

It’s a way to open a direct conversation between your computer and a web server. No UI, no buttons, just pure request and response.


Why programmers need cURL?

When you’re doing backend development or working with APIs, you often need to:

  • Test an API endpoint

  • Send data to a server

  • See exactly what the server returns

  • Debug why a request is failing

Using a browser hides a lot of details. Using cURL shows you everything.

For example, when you build an API in your own server (like with Node/Express), you can instantly test it with cURL without writing any frontend code. It’s fast, lightweight, and perfect for Debugging, Automation scripts, etc.


Making your first request using cURL

The simplest usage of cURL is:

curl https://example.com

When you run the above command, the following happens:

  1. Your computer sends an HTTP GET request to https://example.com

  2. The server responds with some data (usually HTML)

  3. cURL prints that raw response directly in your terminal

You won’t see a rendered webpage like in a browser. You’ll see the actual HTML source.

💡
By default, curl URL sends a GET request to a URL and shows the response body.

Understanding Request

Every web communication has two parts: Request and Response. Let’s explore Request first. It contains things like:

  • Method (GET, POST, PUT, DELETE, etc.)

  • URL

  • Headers

  • Optional body (data you send to the server)

Example request in cURL:

curl -X POST https://api.example.com/users

The -X flag allows you to define the HTTP method (GET, POST, etc.) for the request.


Understanding Response

The server sends a response to your request which contains:

  • Status code (like 200, 404, 500)

  • Headers

  • Body (JSON, HTML, text, etc.)

To see full details including headers, use:

curl -i https://example.com

The output will look something like this:

HTTP/2 200
date: Fri, 30 Jan 2026 13:04:11 GMT
content-type: text/html
...

<!doctype html><html lang="en">...</html>

Let’s break down the different components of a response:

Status Code

We can find a status code in the very first line, which in this example is 200. Status codes tell you whether your request succeeded or failed and why. Classes of Status codes are as follows:

Code Meaning
100-199 Informational responses
200-299 Successful responses
300-399 Redirection messages
400-499 Client error responses
500-599 Server error responses

Response Headers

Everything between the status line and the blank line is made up of headers:

date: Fri, 30 Jan 2026 13:13:51 GMT
content-type: text/html
cf-ray: 9c613aa01ac03b49-BOM
last-modified: Fri, 30 Jan 2026 05:47:18 GMT
...

Headers are metadata about the response. They tell you what type of data is in the body, when did the server generate the response, whatt server software handled the request, etc.

Response Body

After a blank line, the actual data begins:

<!doctype html><html lang="en">...</html>

This part is the real content you asked for. For websites, it’s HTML. For APIs, it’s JSON.


Conclusion

A server response is more than just what you see. The status code, headers, and body each give you important information. By learning to read all three parts, you gain full visibility into how your requests are handled. This makes cURL an incredibly powerful tool for testing and troubleshooting any web API.