To show response headers with curl, use curl -i URL (headers, then the body), curl -I URL (headers only, via a HEAD request) or curl -sS -D - -o /dev/null URL (headers only, via a normal GET). To send a header, add -H "Name: value", once for each header.
We ran every command below on 20 November 2026 with curl 8.22.0 on Windows 11 against httpbin.org, which echoes back the headers it receives, and through a QuanticData proxy. The output is copied from those runs (httpbin's trace header is left out).
Show response headers: four ways
| Option | Request sent | What it prints | Use it when |
|---|---|---|---|
-i | GET | Headers, a blank line, the body | You want to see both |
-I | HEAD | Headers only | The server answers HEAD like GET |
-D - -o /dev/null | GET | Headers only | You want the real GET response without the body |
-v | GET | Request headers (>) and response headers (<) on stderr | Debugging what was sent |
$ curl -sS -D - -o /dev/null https://httpbin.org/json
HTTP/1.1 200 OK
access-control-allow-credentials: true
access-control-allow-origin: *
access-control-expose-headers: Retry-After, RateLimit, RateLimit-Policy, WWW-Authenticate
content-length: 429
content-type: application/json
x-content-type-options: nosniff
date: Fri, 20 Nov 2026 15:39:53 GMT
-D - dumps the headers to standard output (the -), and -o /dev/null throws the body away (NUL in PowerShell or cmd). Replace - with a file name to save them: -D resp-headers.txt -o body.json gave a 9-line header file starting with HTTP/1.1 200 OK and the body in its own file.
-I is not the same request
-I changes the method to HEAD, and a server is free to answer HEAD differently from the GET your browser makes. httpbin's /post URL accepts only POST, so both -I and -D - got HTTP/1.1 405 Method Not Allowed there: the status describes the request you sent, not the page. When the status from -I looks wrong, compare it with -D - -o /dev/null, which keeps the GET.
One header, the status code, or all headers as JSON
The -w option prints values after the transfer, without the rest of the headers:
$ curl -sS -o /dev/null -w "%{http_code}\n" https://httpbin.org/json
200
$ curl -sS -o /dev/null -w "%header{content-type}\n" https://httpbin.org/json
application/json
$ curl -sS -o /dev/null -w "%{header_json}\n" https://httpbin.org/json
{"access-control-allow-credentials":["true"],
"access-control-allow-origin":["*"],
...
"content-type":["application/json"],
"x-content-type-options":["nosniff"],
"date":["Fri, 20 Nov 2026 15:39:55 GMT"]
}
%header{name} is the cleanest way to read one header in a script; %{header_json} gives every header as JSON, each value in a list because a header can repeat.
Headers of every redirect
$ curl -sS -L -I https://github.com/curl/curl/raw/master/README | grep -iE "^HTTP|^location"
HTTP/1.1 302 Found
Location: https://raw.githubusercontent.com/curl/curl/master/README
HTTP/1.1 200 OK
With -L, curl prints one header block per hop, so you can see where a link really leads.
Send custom request headers
Without options, curl sends three headers to an https URL:
$ curl -sS https://httpbin.org/headers
{
"headers": {
"Accept": "*/*",
"Host": "httpbin.org",
"User-Agent": "curl/8.22.0"
}
}
Add your own with -H, one per header:
$ curl -sS -H "X-Test: 42" -H "Accept-Language: de-DE" https://httpbin.org/headers
{
"headers": {
"Accept": "*/*",
"Accept-Language": "de-DE",
"Host": "httpbin.org",
"User-Agent": "curl/8.22.0",
"X-Test": "42"
}
}
| Goal | Option | What httpbin received |
|---|---|---|
| User agent that names your script | -A "my-scraper/1.0 (+https://example.com/bot)" | my-scraper/1.0 (+https://example.com/bot) |
| Referer | -e https://example.com/ | Referer: https://example.com/ |
| Cookie | -b "session=abc123" | Cookie: session=abc123 |
| Replace a default | -H "User-Agent: my-scraper/1.0" | my-scraper/1.0 |
| Remove a default | -H "Accept:" -H "User-Agent:" | Neither header |
| Send an empty header | -H "X-Empty;" | X-Empty: "" |
| Headers from a file | -H @headers.txt | Every line of the file as a header |
| Authorization | -u user:pass or -H "Authorization: ..." | See curl basic auth |
A header ending in a colon with nothing after it removes the header; ending in a semicolon sends it empty. -H @headers.txt reads one Name: value per line; ours held an X-Api-Key and an Accept, and both arrived. With --json, curl sets Content-Type and Accept to application/json for you, as shown in curl POST requests.
Headers through a proxy: -H, --proxy-header and the CONNECT reply
For an https URL, curl asks the proxy for a tunnel and then talks to the site inside it. That changes two things:
$ curl -sS -x http://residentialboson.quanticdata.io:10000 -U "USER-...:PASS" \
-H "X-Site: yes" --proxy-header "X-Proxy-Only: yes" https://httpbin.org/headers
{
"headers": {
"Accept": "*/*",
"Host": "httpbin.org",
"User-Agent": "curl/8.22.0",
"X-Site": "yes"
}
}
$ curl -sS -x http://residentialboson.quanticdata.io:10000 -U "USER-...:PASS" -D - -o /dev/null https://httpbin.org/json
HTTP/1.1 200 Connection Established
HTTP/1.1 200 OK
access-control-allow-credentials: true
...
-Hgoes to the site, inside the tunnel;--proxy-headergoes only to the proxy, so the site never sawX-Proxy-Only.-D -shows two blocks: the proxy's reply to CONNECT, then the site's headers.--suppress-connect-headershides the first block, so scripts that read the first status line get the site'sHTTP/1.1 200 OK.-vshows the tunnel:> CONNECT httpbin.org:443 HTTP/1.1, the Proxy-Authorization line, and the proxy's 200 reply to CONNECT before the site's response.
Request headers matter when a site answers differently to different clients; the defaults above announce curl, and what curl, Python Requests and Chromium each send is compared in HTTP headers explained. A 403 when scraping is covered in 403 Forbidden when scraping. Gateways and SOCKS5 are in how to use a proxy with curl.
We repeated the X-Site echo through Residential Premium and Mobile as well: all three networks passed the header through unchanged. Our residential proxies and mobile proxies come with a Residential Basic free trial.


