Code & computing / QUICK REFERENCE
curl request essentials
Inspect HTTP responses, save files and send deliberate requests with explicit timeout and security behavior.
Inspect responses
- GET a page
curl https://example.comWrites the response body to stdout. [1]
- HEAD request
curl -I https://example.comRequests headers; this is a HEAD method, not a GET without a body. [1]
- Headers plus body
curl -i https://example.comIncludes response headers in output. [1]
- Verbose connection details
curl -v https://example.comDiagnostic output can expose headers and credentials. [1]
- Follow redirects
curl -L https://example.comFollows Location responses; confirm redirected destinations. [1]
- Write headers separately
curl -D headers.txt -o body.html https://example.comWrites or replaces two local files. [1]
- Print status code
curl -sS -o /dev/null -w '%{http_code}\n' https://example.comA 404 does not make plain curl fail by default. [1]
- Fail on HTTP errors
curl --fail-with-body https://example.comNonzero exit for HTTP errors while retaining the body on supported curl versions. [1]
Build requests explicitly
- Request JSON
curl -H 'Accept: application/json' https://example.com- Custom header
curl -H 'X-Request-Label: atlas' https://example.com- Encode GET parameters
curl -G --data-urlencode 'q=hello world' https://example.com- POST form data
curl --data-urlencode 'name=Atlas' https://example.com- POST JSON
curl --json '{"name":"Atlas"}' https://example.comAdds JSON headers and a request body on supported versions. [2][1]
- Send JSON from a file
curl --json @request.json https://example.com
Bound requests and save output
- Connection timeout
curl --connect-timeout 5 https://example.comBounds connection establishment, not the whole transfer. [3][1]
- Whole-operation timeout
curl --max-time 20 https://example.com- Retry selected failures
curl --retry 3 https://example.comReview retry safety before sending non-idempotent requests. [3][1]
- Bound retry period
curl --retry 3 --retry-max-time 30 https://example.com- Quiet but show errors
curl -sS https://example.com- Choose output filename
curl -o page.html https://example.com- Restrict allowed protocols
curl --proto '=https' --proto-redir '=https' -L https://example.com
Reserved placement, separate from reference controls. No ad network is active.
No matching entry. Try a shorter word or clear the search to see the complete sheet.
Sources
cheatsheetatlas.com/sheets/curl/ · Updated 2026-10-19 · curl · modern command-line options