80+ practical curl examples for HTTP requests, headers, authentication, JSON bodies, file upload, cookies, retries, timing, and the flags you forget at 2am
BASICS
curl URL
GET request, body printed to stdout
curl -i URL
Include response headers in output
curl -I URL
HEAD request, only show response headers
curl -v URL
Verbose, show request and response headers
curl -s URL
Silent mode, no progress meter or errors
curl -sS URL
Silent but still show errors (most common combo)
curl --version
Show curl version and supported features
curl --help all
Print every option (the kitchen sink)
HTTP METHODS
curl -X POST URL
POST request (with no body)
curl -X PUT URL
PUT request
curl -X PATCH URL
PATCH request
curl -X DELETE URL
DELETE request
curl -X OPTIONS URL
OPTIONS request (CORS preflight)
curl --get -d "q=foo" URL
GET with query string from -d data
curl -d "x=1&y=2" URL
POST form-encoded (-d implies -X POST)
HEADERS
curl -H "Accept: application/json" URL
Set request header
curl -H "X-Custom: value" -H "X-Other: 2" URL
Multiple headers, repeat -H
curl -H "User-Agent: my-bot/1.0" URL
Override User-Agent header
curl -A "my-bot/1.0" URL
Shortcut for User-Agent
curl -e "https://referer.example" URL
Set Referer header
curl -H "Host: example.com" IP_URL
Override Host header (test SNI / virtual hosts)
curl -H "X-Foo;" URL
Send empty header (semicolon at end)
curl -H "Accept-Encoding: gzip" --compressed URL
Auto-decompress gzip / br response
AUTHENTICATION
curl -u user:pass URL
HTTP Basic auth
curl -u user URL
Basic auth, prompt for password (more secure than inline)