Mastering curl Command Options Quickly | Generated by AI

Home 2026.02

curl (Client URL) is a powerful command-line tool for transferring data using various network protocols. Here’s a thorough guide to its most useful options.

Basic Usage

curl https://example.com

This fetches and displays the content from the URL.

Essential Options

**-o, –output ** — Save output to a file instead of stdout:

curl -o page.html https://example.com

-O, –remote-name — Save with the same filename as the remote file:

curl -O https://example.com/file.zip

-L, –location — Follow redirects (essential for many modern URLs):

curl -L https://example.com

-i, –include — Include HTTP response headers in output:

curl -i https://example.com

-I, –head — Fetch headers only (HEAD request):

curl -I https://example.com

-v, –verbose — Show detailed information about the request/response:

curl -v https://example.com

-s, –silent — Silent mode, no progress or error information:

curl -s https://example.com

HTTP Methods

**-X, –request ** — Specify HTTP method:

curl -X POST https://api.example.com/data
curl -X DELETE https://api.example.com/resource/123

**-d, –data ** — Send POST data (automatically sets POST method):

curl -d "name=John&age=30" https://api.example.com/users
curl -d @data.json https://api.example.com/users  # from file

**–data-urlencode ** — URL-encode data before sending:

curl --data-urlencode "name=John Doe" https://api.example.com

Headers

-H, –header <header> — Add custom headers:

curl -H "Content-Type: application/json" https://api.example.com
curl -H "Authorization: Bearer TOKEN" -H "Accept: application/json" https://api.example.com

**-A, –user-agent ** — Set User-Agent header:

curl -A "Mozilla/5.0" https://example.com

**-e, –referer ** — Set Referer header:

curl -e "https://google.com" https://example.com

Authentication

**-u, –user ** — HTTP Basic Authentication:

curl -u username:password https://api.example.com
curl -u username https://api.example.com  # prompts for password

**–oauth2-bearer ** — OAuth 2.0 Bearer Token:

curl --oauth2-bearer "your_token_here" https://api.example.com

Cookies

**-b, –cookie ** — Send cookies:

curl -b "session=abc123" https://example.com
curl -b cookies.txt https://example.com  # from file

**-c, –cookie-jar ** — Save cookies to file:

curl -c cookies.txt https://example.com

File Uploads

-F, –form <name=content> — Submit form data (multipart/form-data):

curl -F "file=@document.pdf" https://api.example.com/upload
curl -F "name=John" -F "avatar=@photo.jpg" https://api.example.com/profile

**-T, –upload-file ** — Upload file via PUT:

curl -T file.txt https://example.com/upload

Download Options

**-C, –continue-at ** — Resume a download:

curl -C - -O https://example.com/largefile.zip  # auto-detect offset

**–limit-rate ** — Limit transfer speed:

curl --limit-rate 100K https://example.com/file.zip

**-r, –range ** — Download only a range of bytes:

curl -r 0-999 https://example.com/file.zip  # first 1000 bytes

SSL/TLS Options

-k, –insecure — Skip SSL certificate verification (use cautiously):

curl -k https://self-signed.example.com

**–cacert ** — Specify CA certificate:

curl --cacert ca-bundle.crt https://example.com

**–cert ** — Use client certificate:

curl --cert client.pem https://example.com

Timeouts and Retries

**–connect-timeout ** — Maximum connection time:

curl --connect-timeout 10 https://example.com

**-m, –max-time ** — Maximum total operation time:

curl -m 30 https://example.com

**–retry ** — Number of retry attempts:

curl --retry 5 https://example.com

Proxy

-x, –proxy <[protocol://]host[:port]> — Use proxy:

curl -x http://proxy.example.com:8080 https://example.com
curl -x socks5://localhost:9050 https://example.com

**-U, –proxy-user ** — Proxy authentication:

curl -x proxy.example.com:8080 -U user:pass https://example.com

Output Formatting

**-w, –write-out ** — Display custom information:

curl -w "Status: %{http_code}\nTime: %{time_total}s\n" https://example.com

Useful format variables include %{http_code}, %{time_total}, %{size_download}, %{speed_download}.

–compressed — Request compressed response:

curl --compressed https://example.com

Multiple URLs

-Z, –parallel — Process multiple URLs in parallel:

curl -Z https://example.com/file1 https://example.com/file2

You can also use brace expansion:

curl https://example.com/file[1-10].txt
curl https://example.com/{page1,page2,page3}.html

Practical Examples

JSON API request:

curl -X POST https://api.example.com/users \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer TOKEN" \
  -d '{"name":"John","email":"john@example.com"}'

Download with progress bar:

curl -# -o file.zip https://example.com/file.zip

Check website response time:

curl -w "@curl-format.txt" -o /dev/null -s https://example.com

Where curl-format.txt contains:

time_namelookup:  %{time_namelookup}s
time_connect:     %{time_connect}s
time_total:       %{time_total}s

This covers the most commonly used curl options. For the complete list, run curl --help or man curl on your system.


Back Donate