Updated 10 hours ago
Curl has hundreds of options. You don't need to know hundreds of options.
What you need is a mental model: every curl option answers one of five questions about the HTTP conversation you're having. What am I saying? Who am I? How should I connect? What should I do with the response? And the meta-question that makes debugging possible: Show me what's actually happening.
Once you see curl options this way, they stop being flags to memorize and become tools you reach for naturally.
Controlling Output
By default, curl dumps everything to your terminal. These options give you control over where responses go and what information you see.
Save to a File
-o lets you name the file. -O trusts the server's filename.
Silence and Errors
-s suppresses everything—progress bars, errors, all of it. The combination -sS is curl's way of saying "shut up unless something goes wrong." This is what you want in scripts.
Ask Curl About the Request
The -w flag lets you interrogate curl itself about what just happened:
Useful variables:
%{http_code}— The response status%{time_total}— Total time in seconds%{time_namelookup}— How long DNS took%{time_connect}— How long TCP handshake took%{time_appconnect}— How long TLS handshake took%{time_starttransfer}— Time to first byte (server thinking time)%{size_download}— Bytes received
This is how you measure performance without external tools.
Controlling the Request
HTTP Methods
For GET requests, you can skip -X GET—it's the default.
Sending Data
The -d flag implies POST. The @ prefix reads from a file.
File Uploads
-F sends multipart form data—the same format browsers use for file uploads.
Headers
Every -H adds one header. Use this for API keys, content types, custom headers—anything the server needs to know about your request.
HEAD Requests
Ask for headers only, no body. Useful for checking if a resource exists or reading metadata without downloading the whole thing.
Authentication and Identity
Basic Auth
This encodes credentials as Base64 in the Authorization header. Not secure over plain HTTP.
Cookies
Use -c to save, -b to send. For session-based APIs, you'll often do both.
User Agent
Some servers behave differently based on who they think you are.
Connection Behavior
Following Redirects
Without -L, curl stops at redirects and reports the 3xx status. With -L, it follows them like a browser would.
Timeouts
Always set timeouts in scripts. Otherwise a hung server hangs your script forever.
Retries
Retry up to 3 times, waiting 5 seconds between attempts.
Resume Downloads
If the download fails, run the same command again. The -C - tells curl to figure out where it left off.
SSL/TLS
Skip Certificate Verification
Never use this in production. It defeats the entire point of TLS. Use it only for local development with self-signed certificates.
Client Certificates
For mutual TLS where the server wants to verify your identity.
Proxies
Debugging
Verbose Mode
This shows everything: DNS lookup, TCP connection, TLS negotiation, request headers sent, response headers received. When something isn't working, this is where you start.
Full Trace
Even more detail than verbose, including the raw bytes. Use when -v isn't enough.
Force DNS Resolution
Make curl use a specific IP for a hostname. Essential for testing before DNS changes propagate, or for hitting a specific server in a load-balanced setup.
Patterns for Real Work
API Testing
Reliable Downloads
Health Check
Configuration Files
Tired of typing the same options? Put them in ~/.curlrc:
These become defaults for all curl commands.
Frequently Asked Questions About curl Options
Was this page helpful?