curl flags and options reference
Complete reference for curl command-line flags including request methods, headers, authentication, and TLS options.
curl flags and options reference
Complete reference for curl command-line flags including request methods, headers, authentication, and TLS options.
curl Request Flags
| Flag | Description | Example |
|---|---|---|
-X METHOD | Set the HTTP request method (GET, POST, PUT, DELETE, PATCH). | curl -X POST https://api.example.com/data |
-d DATA | Send data in a POST request body. Sets Content-Type to
application/x-www-form-urlencoded. | curl -d "key=value" https://api.example.com/data |
--json DATA | Send JSON data. Automatically sets Content-Type and Accept headers. Requires curl 7.82+. | curl --json '{"key":"value"}' https://api.example.com |
-F FIELD=VALUE | Send multipart form data. Use
@ prefix to upload files. | curl -F "file=@report.pdf" https://api.example.com/upload |
-T FILE | Upload a file via PUT request. | curl -T file.txt https://api.example.com/files/ |
curl Output Flags
| Flag | Description | Example |
|---|---|---|
-o FILE | Save response body to a file. | curl -o output.html https://example.com |
-O | Save using the remote filename. | curl -O https://example.com/file.tar.gz |
-i | Include response headers in the output. | curl -i https://example.com |
-I | Fetch response headers only (HEAD request). | curl -I https://example.com |
-s | Silent mode — suppress progress meter and error messages. | curl -s https://example.com |
-v | Verbose mode — show request/response headers, TLS handshake. | curl -v https://example.com |
-w FORMAT | Write output using a format string after the transfer. | curl -o /dev/null -s -w "%{http_code}" https://example.com |
-C - | Resume a previous download. | curl -C - -O https://example.com/large.iso |
curl Header and Authentication Flags
| Flag | Description | Example |
|---|---|---|
-H HEADER | Add a custom HTTP header. | curl -H "Authorization: Bearer TOKEN" https://api.example.com |
-u USER:PASS | HTTP basic authentication. | curl -u admin:secret https://api.example.com |
-b COOKIES | Send cookies (from a string or file). | curl -b "session=abc123" https://example.com |
-c FILE | Save received cookies to a file. | curl -c cookies.txt https://example.com |
-L | Follow HTTP redirects (301, 302, 307, 308). | curl -L https://example.com/old-url |
--max-redirs N | Limit the number of redirects to follow. | curl -L --max-redirs 3 https://example.com |
curl TLS/SSL Flags
| Flag | Description | Example |
|---|---|---|
-k/
--insecure | Skip SSL certificate verification. For debugging only. | curl -k https://self-signed.example.com |
--cacert FILE | Use a specific CA certificate bundle. | curl --cacert /path/to/ca.crt https://internal.example.com |
--cert FILE | Client certificate for mutual TLS. | curl --cert client.crt --key client.key https://api.example.com |
--tlsv1.2 | Force minimum TLS version 1.2. | curl --tlsv1.2 https://example.com |
--tlsv1.3 | Force TLS version 1.3. | curl --tlsv1.3 https://example.com |
curl Connection Flags
| Flag | Description | Example |
|---|---|---|
--connect-timeout SECS | Maximum time for the TCP connection to establish. | curl --connect-timeout 10 https://example.com |
--max-time SECS | Maximum total time for the entire operation. | curl --max-time 60 https://example.com |
-x PROXY | Use an HTTP or SOCKS proxy. | curl -x http://proxy:8080 https://example.com |
--retry N | Retry failed requests N times. | curl --retry 3 https://example.com |