If you want to use curl to show response headers, you are in the right place. Response headers reveal important details about the server's reply, including status codes, content types, caching rules, cookies, and more. Once you know how to inspect them, debugging APIs and websites becomes much easier.
In this guide, you will learn a few different ways to do it, from quick header checks to full request debugging. We're going to walk through the most useful curl flags, explain common headers, and show practical examples using APIs and real web requests.
By the end, you will know how to inspect headers, troubleshoot requests, and even reproduce browser traffic directly from your terminal.

Quick answer (TL;DR)
If you just want the quickest way to use curl to show response headers, here are the commands you need.
Show only the response headers:
curl -I https://httpbingo.org/html
Show headers and the response body together:
curl -i https://httpbingo.org/html
Show detailed request and response information (verbose debug mode):
curl -v https://httpbingo.org/html
Follow redirects and still inspect headers:
curl -i -L https://httpbingo.org/html
These commands help you quickly inspect status codes, content types, cookies, caching headers, and redirect behavior when debugging APIs or websites.
For a deeper explanation of how HTTP headers work with curl, see this: HTTP headers curl guide.
Understanding HTTP headers with curl
Before we start using curl to show response headers, it helps to understand what is actually happening when your computer talks to a website. Every time you open a page, call an API, or fetch some data, a small conversation happens behind the scenes. That conversation is based on HTTP requests and responses, and headers are a big part of it.
What an HTTP request actually is
One way I like to explain this is with a simple analogy: going to a bar with a friend. You walk up to the bartender and ask for the menu. That is basically a GET request. In this example, the bartender is the server.
Your computer does a similar thing when it loads a page (typically via a browser). It sends a request to a server asking for something like a webpage, an image, or API data, and the server responds with the requested content.
You can do the same from the terminal with curl. Here is a simple GET request to a public testing service:
curl https://httpbingo.org/html
If everything works, curl will download the HTML page and print it directly in your terminal.
What headers are in requests and responses
Now back to the bar for a second. (Or maybe a little longer.) When you ask for the menu, you might also give the bartender some extra information. Maybe you say you prefer English. Or maybe you ask for the regular menu instead of the drinks menu. Maybe you show an ID or a membership card.
Those little pieces of extra information are similar to HTTP headers. Headers are small bits of metadata sent along with a request or a response. They help both sides understand how the data should be handled.
When your computer sends a request, it can include request headers such as:
- what formats it accepts
- what language it prefers
- what client is making the request
When the server sends a response, it includes response headers. These can describe things like:
- the type of content being returned
- the size of the response
- caching rules
- which server handled the request
Every website and API you interact with uses headers. They are part of the normal HTTP conversation.
Requests in the browser and with curl
If you are curious, you can already see headers directly in your browser. Open any website, then open Developer Tools (usually F12). In the Network tab, click on a request and you will see sections called Request Headers and Response Headers. This is the same information exchanged every time your browser loads a page or calls an API. We will look at this workflow in more detail later.
curl lets you inspect the same data from the command line. For now, we are just sending a basic request to make sure curl works:
curl https://httpbingo.org/html
This command sends a simple GET request and prints the HTML response in your terminal.
- On macOS and Linux, curl is usually already installed and available in the terminal.
- On Windows, recent versions include curl in PowerShell and Command Prompt. If your system does not recognize the command, you may need to install it or update your environment.
In the next sections, we will start using curl to show response headers and see exactly what the server sends back.
Core curl commands to show response headers
Here are the go-to commands for showing response headers with curl. You can copy and paste these to quickly inspect what a server returns.
- Headers only:
curl -I https://httpbingo.org/html - Headers + body:
curl -i https://httpbingo.org/html - Save headers to a file:
curl -D headers.txt https://httpbingo.org/html - Quiet output but still show errors:
curl -sS -I https://httpbingo.org/html
A few brief notes for different OS:
- On macOS and Linux you can run these commands directly in the Terminal.
- On Windows, use PowerShell or Command Prompt. If a URL contains
&, PowerShell may treat it specially, so wrap the URL in quotes like"https://httpbingo.org/get?page=2&limit=10".
Want redirects too? Check this: curl follow redirect tutorial
Show only response headers
Use -I (capital i) to fetch only response headers. Under the hood, curl sends a HEAD request, which asks for metadata without downloading the full response body.
curl -I https://httpbingo.org/html
Typical output looks like this (your exact values will differ):
HTTP/1.1 200 OK
access-control-allow-credentials: true
access-control-allow-origin: *
content-type: text/html; charset=utf-8
date: Wed, 04 Mar 2026 16:21:12 GMT
server: Fly/eb4db471f (2026-03-03)
via: 1.1 fly.io, 1.1 fly.io
What to look at first:
- The status line:
HTTP/1.1 200 OKmeans the request worked. If you see301or302, it means a redirect. If you see401or403, you likely need authentication or access is restricted. content-type: tells you what the server returned, such as HTML or JSON.server: not always present, but when it is, it shows what software handled the request.
If the site redirects, curl -I will show the redirect response instead of the final destination. In that case, add -L so curl follows the redirects and shows the final headers:
curl -I -L https://httpbingo.org/redirect/2
Show headers and body together
Use -i (lowercase i) to print both the response headers and the body in the same output. This is useful when you want to see the metadata and the returned content together.
curl -i https://httpbingo.org/html
In the output, headers appear first. Then there is a blank line, and the body starts (that empty line separates headers from the response content). If you scroll down, you will usually see HTML begin right after it, for example <!doctype html> or <html>:
HTTP/1.1 200 OK
content-type: text/html; charset=utf-8
date: Wed, 04 Mar 2026 16:23:19 GMT
transfer-encoding: chunked
server: Fly/eb4db471f (2026-03-03)
<!DOCTYPE html>
<html>
<head>
...
If the output feels noisy and you only want the important parts, add -s for “silent” mode:
curl -is https://httpbingo.org/html
This keeps the headers and body but removes the progress meter so the output is easier to read. Note that this parameter might also hide errors; in that case, pair it with -S.
Save response headers to a file
Use -D (or --dump-header) to write response headers to a file. This is useful when you want to compare runs, share headers with someone, or parse them later.
Save headers to headers.txt and still print the body:
curl -D headers.txt https://httpbingo.org/html
Save headers to headers.txt but discard the body:
curl -D headers.txt -o /dev/null https://httpbingo.org/html
On Windows, /dev/null does not exist. Use NUL instead:
curl -D headers.txt -o NUL https://httpbingo.org/html
You can also print headers directly to the terminal by using - instead of a file name:
curl -D - https://httpbingo.org/html
Here - means "send the headers to stdout", so curl prints them straight in the terminal.
Inspecting API responses with headers (JSON and XML)
When you work with APIs, headers become even more important. Most APIs return structured data like JSON or XML, and response headers tell you how to interpret that data and how the API behaves.
For example, headers can reveal things like:
- what format the API returned (
Content-Type) - whether the response is cached (
Cache-Control) - how many requests you have left (
X-RateLimit-*headers) - authentication or permission issues
When debugging an API call, headers are usually the first thing to check. They quickly show whether the server accepted your request, what format it returned, and whether there are limits or errors you should know about. curl makes it easy to inspect this information while calling an API endpoint.
Check JSON API headers with curl
Let's start with a JSON API example. We'll use a public testing endpoint that returns JSON.
curl -i https://httpbingo.org/json
Because we've added -i, curl printed both the response headers and the JSON body.
Typical output might start like this:
HTTP/1.1 200 OK
content-type: application/json; charset=utf-8
date: Wed, 04 Mar 2026 16:28:49 GMT
content-length: 421
server: Fly/eb4db471f (2026-03-03)
{
"slideshow": {
"author": "Yours Truly",
"date": "date of publication",
"slides": [
// ...
]
}
}
The key header here is content-type. When it says application/json, it means the response body is JSON and your program or script should parse it accordingly. You will often also see caching headers like cache-control, which tell clients how long the response can be reused.
If your API request includes query parameters, curl works the same way. Just include them in the URL:
curl -i "https://httpbingo.org/get?limit=10"
If you want a detailed debug view of everything curl sends and receives, you can use -v instead of -i.
For a deeper walkthrough of working with JSON responses, see this guide: curl get JSON guide
Check XML API headers with curl
Some APIs still return XML instead of JSON. The process with curl is exactly the same: you just check the response headers to confirm the format.
Here is a simple example using a testing endpoint:
curl -i https://httpbingo.org/xml
The headers might look like this:
HTTP/1.1 200 OK
content-type: application/xml
date: Wed, 04 Mar 2026 16:30:08 GMT
content-length: 522
In this case, the content-type header tells us the response body is XML.
When debugging API integrations, checking the response headers first is often the fastest way to see what is going on before digging into the full response body.
Sending request headers with curl
So far we focused on how to inspect response headers. But when working with APIs, you often also need to send headers as part of the request. This is not the main topic of this guide, but it is useful to know because many APIs expect headers for authentication, content negotiation, or rate limiting.
The most common way to send headers with curl is the -H flag. For example, sending an API token:
curl -H "Authorization: Bearer YOUR_TOKEN" https://httpbingo.org/bearer
You can also tell the API what response format you prefer. This is done with the Accept header:
curl -H "Accept: application/json" https://httpbingo.org/bearer
Sometimes you may need to send multiple headers in the same request:
curl -H "Authorization: Bearer YOUR_TOKEN" \
-H "Accept: application/json" \
https://httpbingo.org/bearer
Another useful option is --compressed. Many APIs return compressed responses, and this flag tells curl to automatically handle them:
curl --compressed https://httpbingo.org/json
In practice, you will often combine these options with the header inspection techniques we covered earlier.
Using browser DevTools to build better curl header commands
Sometimes the request you want to reproduce is not simple. Modern websites send many headers, cookies, tokens, and query parameters. Rebuilding that request manually can take time; a faster option is to let the browser generate the curl command for you.
Most browsers allow you to copy a request from the Network tab as a complete curl command. It includes the URL, method, headers, cookies, and sometimes even the request body. You can paste it directly into a terminal and replay the exact request. This is especially useful when debugging APIs, working with login sessions, or inspecting JavaScript-heavy pages that make background requests.
Copy curl with headers from Chrome DevTools
Here is the quick workflow in Chrome.
- Open the website you want to inspect.
- Open Developer Tools (press F12 or right-click → Inspect).
- Go to the Network tab.
- Reload the page so Chrome captures the requests.
- Use the filter box or tabs like Fetch/XHR or Doc to find the request you care about.
- Right-click the request.
- Click Copy → Copy as cURL.

Now paste the command into your terminal. You will see a long curl command with multiple -H headers and sometimes cookies.
From there, you can modify the command to inspect headers. For example, you might add -i or -v:
curl -i https://httpbingo.org/html
This lets you replay the same request and inspect the response headers in your terminal.
If you want a deeper walkthrough with screenshots, check this guide: extract curl from Chrome
Copy curl with headers from Firefox
Firefox works almost the same way. These steps also apply to related browsers like LibreWolf or other Firefox-based builds.
- Open the page you want to inspect.
- Press F12 to open Developer Tools.
- Go to the Network tab.
- Reload the page to capture requests.
- Find the request you want in the list.
- Right-click it.
- Choose Copy → Copy as cURL.

Paste the command into your terminal and run it. The generated command already includes most of the headers your browser sent.
Copy curl with headers from Safari
Safari hides its developer tools by default, so you need to enable them once.
- Open Safari → Settings → Advanced.
- Enable Show features for web developers.
- Open the webpage you want to inspect.
- Click Develop → Show Web Inspector.
- Go to the Network tab.
- Reload the page to capture requests.
- Right-click the request you want and copy it as curl.

After that, paste the command into your terminal and run it. The generated command includes the same headers your browser sent, making it easy to replay the request and inspect response headers with curl.
Tips for debugging with curl headers
Once you know how to use curl to show response headers, it becomes a powerful debugging tool. Headers often reveal problems much faster than reading the entire response body.
Here are some practical ways to use curl headers when something does not behave the way you expect.
Debug redirects
Some websites redirect requests before returning the final page. For example, a site might redirect from HTTP to HTTPS, or from /login to another endpoint.
You can detect redirects by inspecting the response headers. A convenient testing endpoint is:
curl -i https://httpbingo.org/redirect/2
This endpoint triggers a redirect chain. In the output, you may see status codes like 301 (permanent redirect) or 302 (temporary redirect).
HTTP/1.1 302 Found
location: /relative-redirect/1
The location header tells the client where the request should go next.
If you want curl to automatically follow redirects and show the final response, add the -L flag:
curl -i -L https://httpbingo.org/redirect/2
To see the full redirect chain with additional debug details, combine it with -v:
curl -v -L https://httpbingo.org/redirect/2
This shows every request and response along the way.
Check caching behavior
Caching issues can cause confusing bugs, especially when APIs or pages return outdated content. Headers like Cache-Control, ETag, and Expires control how responses are cached.
You can inspect caching headers with:
curl -I https://httpbingo.org/cache/3600
Example output might include:
HTTP/1.1 200 OK
cache-control: public, max-age=3600
content-type: application/json; charset=utf-8
Here max-age=3600 means the response may be cached for one hour.
Some servers also include an ETag header: this is a unique identifier for a specific version of a resource. When the content changes, the ETag changes too, allowing clients to check whether they need to download the resource again.
Inspect cookies
Many websites and APIs rely on cookies for sessions and authentication. When a server sets a cookie, it appears in the Set-Cookie response header.
You can inspect it with:
curl -i "https://httpbingo.org/cookies/set?cookie1=v1&cookie2=v2"
You might see something like:
set-cookie: cookie1=v1; HttpOnly
set-cookie: cookie2=v2; HttpOnly
If you want curl to store cookies for later requests, use the cookie jar option:
curl -c cookies.txt "https://httpbingo.org/cookies/set?cookie1=v1&cookie2=v2"
This saves cookies to cookies.txt so they can be reused in future requests.
Check authentication problems
If an API requires authentication, headers often reveal what went wrong.
For example, if you forgot to include a token, you might see:
HTTP/1.1 401 Unauthorized
Some APIs also include headers that describe rate limits or authentication status.
When testing authenticated requests, send your token like this:
curl -i -H "Authorization: Bearer secret_token" https://httpbingo.org/bearer
If the request still fails, check the response headers first. They often contain hints about missing permissions, expired tokens, or incorrect request formats.
Look for SSL or connection details
If you suspect TLS or connection issues, verbose mode is your friend:
curl -v https://httpbingo.org/html
Verbose output shows details about the connection process, TLS handshake, and all request and response headers. This can help identify certificate problems, protocol mismatches, or unexpected redirects.
Turn curl header commands into reusable code
Once you have a curl command that works and shows the required headers, you can easily turn it into reusable code. This is a very common workflow when building scripts, integrations, or automation tools. The idea is simple: use curl to figure out the correct request first. Once everything works, convert that working command into code for your favorite programming language.
For example, imagine you get a request working like this:
curl -i -H "Authorization: Bearer YOUR_TOKEN" https://httpbingo.org/bearer
This command already contains all the necessary stuff: the endpoint, headers, and authentication method. Instead of rebuilding the same request from scratch in your application, you can convert it directly into a ready-to-use code snippet.
Most developers follow a workflow like this:
- Test and debug the request with curl.
- Make sure the headers and response look correct.
- Convert the working curl command into code.
- Drop the generated snippet into a script or an application.
The command above could easily become a request in Python, JavaScript, Go, or many other languages.
Instead of translating the request manually, you can use a tool that converts curl commands into code for dozens of languages.
Try it here: curl to code converter.
Just paste your curl command, choose your language, and the tool will generate the equivalent code snippet.
This is especially helpful when the request includes multiple headers, cookies, or authentication tokens. The converter keeps everything intact and saves you from rewriting the request by hand.
Start using curl headers in real projects
Now you know how to use curl to show response headers, inspect APIs, and debug requests. The next step is to start using these commands in real workflows. Headers play a huge role when working with APIs, scraping websites, or troubleshooting production issues. They tell servers what kind of client you are, what data you accept, and how the response should be handled.
In practice, developers often use curl to quickly investigate things like:
- why an API request is failing
- whether a site is redirecting traffic
- which cookies or authentication headers are required
- how caching headers affect responses
- what content type a server returns
Once you can inspect and reproduce requests with curl, you have a powerful debugging tool right in your terminal. This skill is also useful when working with scraping infrastructure as many modern websites behave differently depending on the headers they receive. If a request looks suspicious or incomplete, the server may block it or return different content.
That is why tools like ScrapingBee work best when your requests include the right headers and mimic real browser traffic. A reliable web scraping API becomes much easier to use when you understand how headers work and how to inspect them with curl.
So try it yourself. Open your terminal, run a few curl requests, inspect the response headers, and experiment with real APIs and websites.
Frequently asked questions (FAQs)
How can I copy a curl request with headers from Chrome?
Open Chrome DevTools, go to the Network tab, reload the page, then right-click the request you want and choose Copy → Copy as cURL. This copies the full request, including headers, so you can replay it in your terminal. See the full guide: Chrome curl extraction tutorial.
How do I see headers when calling an XML API with curl?
Use curl -i or curl -I when requesting the XML endpoint. These flags display the response headers so you can confirm values like Content-Type: application/xml and charset information. This helps verify that the API returned XML correctly. See the full walkthrough: curl get XML guide.
How do I copy a curl command with headers from Safari?
Enable the Develop menu in Safari settings, open Web Inspector, and go to the Network tab. Reload the page, right-click a request, and copy it as a curl command. You can then run it in your terminal to inspect the headers. Full instructions: Safari curl extraction tutorial.
Where can I practice using curl headers on real web scraping projects?
A good way to practice is by testing requests against real websites and APIs while inspecting their headers with curl. This helps you understand authentication, cookies, and browser-like requests. You can build and test these workflows using the ScrapingBee web scraping API.

Ilya is an IT tutor and author, web developer, and ex-Microsoft/Cisco specialist. His primary programming languages are Ruby, JavaScript, Python, and Elixir. He enjoys coding, teaching people and learning new things. In his free time he writes educational posts, participates in OpenSource projects, tweets, goes in for sports and plays music.
