cURL HTTP and API Workflows/Write headers to a file

Store response headers separately from the body.

Section: Response Inspection

Write headers to a file

bash
bash
curl -D headers.txt -o body.html https://example.com
Explanation

This keeps response body and headers in separate files.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Response Inspection
Verbose HTTP/TLS details
Show detailed request and response conversation.
OpenIn sheetbashsame section
Full ASCII trace
Capture a detailed ASCII trace of the transfer.
OpenIn sheetbashsame section
Request compressed response
Ask the server for a compressed response body.
OpenIn sheetbashsame section
Save ETag metadata
Store ETag metadata for conditional requests.
OpenIn sheetbashsame section
Conditional request with ETag
Use a saved ETag to avoid downloading unchanged content.
OpenIn sheetbashsame section
Conditional request by modification time
Only fetch if the remote file is newer than a local file.
OpenIn sheetbashsame section