# curl Show Response Headers and Send Headers

> Show response headers with curl -i, -I, -D - or -w, and send custom headers with -H, -A, -e and -b. Real output, header files, and headers through a proxy.

[Home](https://quanticdata.io/) / [Blog](https://quanticdata.io/blog/) / curl Show Response Headers and Send Headers

# curl headers: show response headers and send custom request headers

Proxies · Nov 20, 2026 · 5 min read · By [Aldo Morese](https://quanticdata.io/about/), founder of QuanticData

![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.](https://quanticdata.io/blog/curl-headers/hero.webp?v=20261120h)

On this page

- [Show response headers: four ways](https://quanticdata.io/blog/curl-headers/#show-response-headers-four-ways)
- [One header, the status code, or all headers as JSON](https://quanticdata.io/blog/curl-headers/#one-header-the-status-code-or-all-headers-as-json)
- [Send custom request headers](https://quanticdata.io/blog/curl-headers/#send-custom-request-headers)
- [Headers through a proxy: -H, --proxy-header and the CONNECT reply](https://quanticdata.io/blog/curl-headers/#headers-through-a-proxy-h-proxy-header-and-the-connect-reply)

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.

**Run it on the free credit.** Every QuanticData account gets $2 of free API usage per month.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-lead&utm_content=curl-headers) · [Explore Residential Proxies from $0.80/GB](https://quanticdata.io/residential-proxies/)

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 |

```bash
$ 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:

```bash
$ 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

```bash
$ 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.

**Try it on your own targets.** Every QuanticData account gets $2 of free API usage per month.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-inline&utm_content=curl-headers) · [Explore Residential Proxies from $0.80/GB](https://quanticdata.io/residential-proxies/)

## Send custom request headers

Without options, curl sends three headers to an https URL:

```bash
$ 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:

```bash
$ 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](https://quanticdata.io/blog/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](https://quanticdata.io/blog/curl-post-request/).

## 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:

```bash
$ 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](https://quanticdata.io/blog/http-headers-explained/). A 403 when scraping is covered in [403 Forbidden when scraping](https://quanticdata.io/blog/web-scraping-403-forbidden/). Gateways and SOCKS5 are in [how to use a proxy with curl](https://quanticdata.io/blog/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](https://quanticdata.io/residential-proxies/) and [mobile proxies](https://quanticdata.io/mobile-proxies/) come with a [Residential Basic free trial](https://quanticdata.io/residential-proxy-free-trial/).

### Sources & further reading

- [curl manual: -H, --header](https://curl.se/docs/manpage.html#-H)
- [curl manual: -D, --dump-header](https://curl.se/docs/manpage.html#-D)
- [curl manual: -w, --write-out](https://curl.se/docs/manpage.html#-w)
- [curl manual: --proxy-header](https://curl.se/docs/manpage.html#--proxy-header)
- [httpbin.org](https://httpbin.org/)

## FAQ

Quick answers on curl show response headers.

[Something else? Ask us](mailto:hello@quanticdata.io)

### 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.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-end&utm_content=curl-headers) · [Explore Residential Proxies from $0.80/GB](https://quanticdata.io/residential-proxies/)

## Related reading

- [curl Timeout: --max-time, --connect-timeout](https://quanticdata.io/blog/curl-timeout/): Proxies · Use --max-time (-m) to cap the whole request and --connect-timeout to cap the connection. Below: the exact "curl: (28)" lines we triggered, what curl did with no timeout at all (21 seconds on Windows), retries, stall detection with --speed-limit, and how both timeouts behave through a proxy.
- [curl Basic Auth: -u, Header, .netrc, Proxy](https://quanticdata.io/blog/curl-basic-auth/): Proxies · curl -u user:password sends HTTP basic authentication: curl base64-encodes the pair into an Authorization header. Below: the header we captured with -v, the same header built by hand, passwords with colons and @, the prompt, .netrc, digest, and why a proxy login goes in -U, not -u.
- [curl Download File: -O, -o, -L and Resume](https://quanticdata.io/blog/curl-download-file/): Proxies · curl -O URL saves the file under its remote name, curl -o name URL under the name you choose, and -L follows redirects such as GitHub's. Below: every option run for real, including the 0-byte file a 302 leaves behind, a resumed download that matched the original byte for byte, and 1 MB through residential and mobile proxies.

---

Source: https://quanticdata.io/blog/curl-headers/ · Site index for AI: https://quanticdata.io/llms.txt
