curl command snippets

Copy-paste-ready curl commands for API testing, file downloads, and HTTP debugging.

curl command snippets

Copy-paste-ready curl commands for API testing, file downloads, and HTTP debugging.

Check HTTP Response Status Code with curl

curl returns only the status code with -w and discards the body:

curl -o /dev/null -s -w "%{http_code}\n" https://example.com

Download a File and Show Progress with curl

curl downloads a file with a progress bar:

curl -# -O https://example.com/large-file.tar.gz

Send a POST Request with Form Data Using curl

curl sends URL-encoded form data:

curl -d "username=admin&password=secret" https://example.com/login

Send a JSON POST Request with curl

curl sends a JSON body with automatic Content-Type header:

curl --json '{"name":"Alice"}' https://api.example.com/users

Test an API Endpoint with Timing Information Using curl

curl shows DNS lookup, TCP connect, TLS handshake, and total transfer times:

curl -o /dev/null -s -w "DNS: %{time_namelookup}s\nConnect: %{time_connect}s\nTLS: %{time_appconnect}s\nTotal: %{time_total}s\n" https://example.com

View Response Headers Only with curl

curl sends a HEAD request and displays the headers:

curl -I https://example.com

Save Cookies from a Response and Resend Them with curl

curl saves cookies from a login response and reuses them:

curl -c cookies.txt -d "user=admin&pass=secret" https://example.com/login
curl -b cookies.txt https://example.com/dashboard