Documentation Python quickstart Blog Free tools Enterprise solutions hello@quanticdata.ioLog in

curl headers: show response headers and send custom request headers

Reading and sending HTTP headers with curl: -i shows response headers and body, -I sends a HEAD request and shows headers only, -D - with -o /dev/null shows the headers of a normal GET, and -w with %header{content-type} prints one header; the card lists the options that send headers: -H, -A for the user agent, -e for the referer, -b for cookies.
Reading and sending HTTP headers with curl: -i shows response headers and body, -I sends a HEAD request and shows headers only, -D - with -o /dev/null shows the headers of a normal GET, and -w with %header{content-type} prints one header; the card lists the options that send headers: -H, -A for the user agent, -e for the referer, -b for cookies.

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

OptionRequest sentWhat it printsUse it when
-iGETHeaders, a blank line, the bodyYou want to see both
-IHEADHeaders onlyThe server answers HEAD like GET
-D - -o /dev/nullGETHeaders onlyYou want the real GET response without the body
-vGETRequest headers (>) and response headers (<) on stderrDebugging 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"
  }
}
GoalOptionWhat 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.txtEvery 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
...
  • -H goes to the site, inside the tunnel; --proxy-header goes only to the proxy, so the site never saw X-Proxy-Only.
  • -D - shows two blocks: the proxy's reply to CONNECT, then the site's headers. --suppress-connect-headers hides the first block, so scripts that read the first status line get the site's HTTP/1.1 200 OK.
  • -v shows 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.

Sources & further reading

FAQ

Quick answers on curl show response headers.

Something else? Ask us

How do I show response headers with curl?

curl -i URL prints the headers and then the body. For headers only, use curl -sS -D - -o /dev/null URL, which keeps the normal GET request, or curl -I URL, which sends a HEAD request.

What is the difference between curl -i and -I?

-i sends the normal request and includes the response headers before the body. -I sends a HEAD request and prints only the headers; some servers answer HEAD with a different status, such as 405.

How do I send a custom header with curl?

Add -H "Name: value", for example curl -H "X-Test: 42" URL. Repeat -H for each header, or put them in a file, one per line, and use -H @headers.txt.

How do I print a single response header with curl?

Use -w "%header{name}" with -o /dev/null: curl -sS -o /dev/null -w "%header{content-type}" URL printed application/json. %{header_json} prints them all as JSON.

How do I remove a header curl sends by default?

Give the header name with a colon and no value: -H "User-Agent:" or -H "Accept:". To send a header with an empty value, end it with a semicolon: -H "X-Empty;".

Does curl -H send headers to the proxy?

For https URLs, no: -H headers go to the site inside the tunnel. Use --proxy-header for headers meant for the proxy. In our test the site received X-Site and never saw the --proxy-header value.

Your headers, a home or carrier IP

Residential and mobile proxies that pass your request headers through unchanged, ready for curl -x and -U.

Related reading