These curl recipes show you how to print HTTP headers from a curl response. By default, curl doesn't print the response headers. It only prints the response body. To print the response headers, too, use the -i command line argument.

curl -i

This recipe uses the -i argument that includes the HTTP headers in the output. It makes a GET request to and when it receives a response, it first prints the headers, then a blank link, and then the response. Many other online resources, erroneously, mention using the capital -I option but this option makes a HEAD request and not a GET request, which has a very different behavior.

curl -s -o /dev/null -D -

For some reason, printing ONLY the response headers (and ignoring the response body) is almost impossible in curl. This essential, basic, and often used and needed operation was missed by curl developers! When testing things, you have to do this operation dozens of times, yet you can't. There's no flag to do it. The only way is to combine three different arguments to accomplish this. The first is -s that silences curl (makes it hide progress bar and errors). The second is -o /dev/null (or -o NUL on Windows) that discards the response body, and the third is -D - that dumps headers to a file, and in this case, the file is -, which is stdout. By combining all three, curl miraculously prints only the response headers.

Created by Browserling

These curl recipes were written down by me and my team at Browserling. We use recipes like this every day to get things done and improve our product. Browserling itself is an online cross-browser testing service powered by alien technology. Check it out!

Secret message: If you love my curl recipe, then I love you, too! Use coupon code CURLLING to get a discount at my company.