📖 Guide
Curl — Complete Reference
Curl command-line reference for HTTP requests, authentication, file transfers, debugging, and common API patterns.
81 commands across 11 categories
Basic RequestsHTTP MethodsHeadersAuthenticationData & POSTFile Upload/DownloadSSL/TLSCookiesProxyDebugging & VerboseCommon Patterns
Basic Requests
| Command | Description |
|---|---|
curl https://example.com | Simple GET request (output to stdout) |
curl -o file.html https://example.com | Save output to a file |
curl -O https://example.com/file.zip | Save with remote filename |
curl -L https://example.com | Follow redirects (3xx responses) |
curl -s https://api.example.com/data | Silent mode — suppress progress meter |
curl -sS https://api.example.com/data | Silent but show errors |
curl -f https://api.example.com/data | Fail silently on HTTP errors (no output on 4xx/5xx) |
curl --compressed https://example.com | Request compressed response (gzip, deflate, br) |
HTTP Methods
| Command | Description |
|---|---|
curl -X GET https://api.example.com/users | Explicit GET request |
curl -X POST https://api.example.com/users | POST request |
curl -X PUT https://api.example.com/users/1 | PUT request (full replace) |
curl -X PATCH https://api.example.com/users/1 | PATCH request (partial update) |
curl -X DELETE https://api.example.com/users/1 | DELETE request |
curl -I https://example.com | HEAD request — fetch headers only |
curl -X OPTIONS https://api.example.com | OPTIONS request (CORS preflight) |
Headers
| Command | Description |
|---|---|
curl -H "Content-Type: application/json" URL | Set a request header |
curl -H "Accept: application/json" URL | Set Accept header |
curl -H "Authorization: Bearer TOKEN" URL | Bearer token auth header |
curl -H "X-Custom: value" -H "Another: val" URL | Multiple custom headers |
curl -H "Content-Type:" URL | Remove a default header (empty value) |
curl -A "MyApp/1.0" URL | Set User-Agent header |
curl -e "https://referrer.com" URL | Set Referer header |
curl -D headers.txt URL | Dump response headers to a file |
Authentication
| Command | Description |
|---|---|
curl -u user:pass https://api.example.com | Basic authentication |
curl -u user https://api.example.com | Basic auth — prompt for password |
curl -H "Authorization: Bearer TOKEN" URL | Bearer token (OAuth2, JWT) |
curl --digest -u user:pass URL | HTTP Digest authentication |
curl --negotiate -u : URL | Kerberos/SPNEGO authentication |
curl -n URL | Use credentials from ~/.netrc file |
curl --oauth2-bearer TOKEN URL | OAuth2 bearer token (curl 7.87+) |
Data & POST
| Command | Description |
|---|---|
curl -d "name=John&age=30" URL | POST form data (application/x-www-form-urlencoded) |
curl -d '{"name":"John"}' -H "Content-Type: application/json" URL | POST JSON data |
curl -d @data.json -H "Content-Type: application/json" URL | POST data from file |
curl --data-urlencode "q=hello world" URL | URL-encode data automatically |
curl -d @- URL <<< '{"key":"val"}' | POST data from stdin |
curl --json '{"name":"John"}' URL | Shorthand for JSON POST (curl 7.82+, sets headers) |
curl -d '' -X POST URL | POST with empty body |
curl --data-binary @file.bin URL | POST binary data without processing |
File Upload/Download
| Command | Description |
|---|---|
curl -F "file=@photo.jpg" URL | Upload file as multipart form data |
curl -F "file=@photo.jpg;type=image/jpeg" URL | Upload with explicit MIME type |
curl -F "file=@doc.pdf" -F "name=report" URL | Upload file with additional form fields |
curl -T file.txt ftp://ftp.example.com/ | Upload via FTP (PUT) |
curl -O -J -L URL | Download with server-suggested filename (-J) |
curl -C - -O URL | Resume interrupted download |
curl --limit-rate 1M -O URL | Limit download speed to 1 MB/s |
curl -o /dev/null -w '%{speed_download}' URL | Measure download speed |
SSL/TLS
| Command | Description |
|---|---|
curl -k https://self-signed.example.com | Skip SSL certificate verification (insecure) |
curl --cacert ca.crt https://example.com | Use custom CA certificate |
curl --cert client.crt --key client.key URL | Client certificate authentication |
curl --tlsv1.2 URL | Force minimum TLS version 1.2 |
curl --tlsv1.3 URL | Force TLS 1.3 |
curl -w '%{ssl_verify_result}' URL | Show SSL verification result code |
Proxy
| Command | Description |
|---|---|
curl -x http://proxy:8080 URL | Use HTTP proxy |
curl -x socks5://proxy:1080 URL | Use SOCKS5 proxy |
curl -x http://user:pass@proxy:8080 URL | Proxy with authentication |
curl --noproxy "*.local,localhost" URL | Bypass proxy for specific hosts |
curl -x socks5h://proxy:1080 URL | SOCKS5 with DNS through proxy |
curl --proxy-insecure -x https://proxy:443 URL | Skip proxy SSL verification |
Debugging & Verbose
| Command | Description |
|---|---|
curl -v URL | Verbose output — show request/response headers |
curl -vvv URL | Extra verbose (includes SSL handshake details) |
curl --trace trace.log URL | Full hex dump of all data to file |
curl --trace-ascii trace.log URL | ASCII trace dump (more readable) |
curl -w '\n%{http_code}\n' URL | Print HTTP status code after response |
curl -w '%{time_total}s\n' -o /dev/null -s URL | Measure total request time |
curl -w '%{time_namelookup} %{time_connect} %{time_total}' URL | Detailed timing breakdown |
curl --stderr errors.log URL | Redirect stderr to file |
Common Patterns
| Command | Description |
|---|---|
curl -sS URL | jq '.' | Fetch JSON and pretty-print with jq |
curl -s -o /dev/null -w '%{http_code}' URL | Get only the HTTP status code |
curl --retry 3 --retry-delay 2 URL | Retry failed requests with delay |
curl --connect-timeout 5 --max-time 30 URL | Set connection and total timeout |
curl -Z -O URL1 -O URL2 -O URL3 | Parallel downloads (curl 7.66+) |
curl -K config.txt | Read options from config file |
curl -w '@format.txt' URL | Custom output format from file |
while ! curl -sf URL; do sleep 5; donee.g. Useful in CI/CD pipelines | Wait for service to become available |
curl -X POST -H 'Content-Type: application/json' -d '{"text":"hello"}' https://hooks.slack.com/... | Send Slack webhook notification |
📖 Free, searchable command reference. Bookmark this page for quick access.