curl Commands Cheatsheet
curl options for GET/POST, headers, auth, file download, and more
Your data never leaves the browser — all processing is done locally 0 server requests
Basic Requests
-
curl https://example.comSend a GET request and print the response body
-
curl -o 파일명 URLSave the response to a specified filename
-
curl -O URLSave the response using the filename from the URL
-
curl -L URLFollow redirects (tracks Location headers)
-
curl -s URLRun silently without showing progress
-
curl -sS URLSuppress progress but still show errors
-
curl -v URLPrint full request and response including headers (for debugging)
HTTP Methods
-
curl -X POST URLSend a POST request
-
curl -X PUT URLSend a PUT request
-
curl -X PATCH URLSend a PATCH request
-
curl -X DELETE URLSend a DELETE request
Sending Data & Body
-
curl -d "key=value&foo=bar" URLPOST form data (application/x-www-form-urlencoded)
-
curl -d '{"key":"value"}' -H 'Content-Type: application/json' URLPOST a JSON body
-
curl -d @파일.json -H "Content-Type: application/json" URLSend a file's contents as the request body
-
curl -F "file=@파일경로" URLUpload a file as multipart/form-data
Headers & Authentication
-
curl -H "Authorization: Bearer 토큰" URLAdd a Bearer token authorization header
-
curl -H "X-Api-Key: 키값" URLAdd a custom header
-
curl -u 사용자:비밀번호 URLUse HTTP Basic authentication
-
curl -H "Cookie: name=value" URLSend a cookie manually
-
curl -b cookies.txt URLRead and send cookies from a file
-
curl -c cookies.txt URLSave response cookies to a file
Inspecting Responses
-
curl -I URLPrint only response headers (HEAD request)
-
curl -w "%{http_code}" -o /dev/null -s URLPrint only the HTTP status code
-
curl -w "\ntime: %{time_total}s\n" URLMeasure and display the total response time
TLS & Proxy
-
curl -k URLSkip SSL certificate verification (test environments only, never use in production)
-
curl --cacert cert.pem URLUse a custom CA certificate
-
curl -x http://proxy:8080 URLRoute the request through an HTTP proxy
Other Useful Options
-
curl -C - -O URLResume an interrupted download
-
curl --limit-rate 1M URLLimit download speed to 1 MB/s
-
curl --retry 3 URLRetry up to 3 times on failure
-
curl --connect-timeout 10 URLSet the connection timeout to 10 seconds
curl: The Swiss Army Knife for HTTP
curl is the most versatile command-line tool for sending HTTP requests. It handles REST API testing, file downloads, authentication headers, response time measurement, and much more. The -v flag prints full request and response headers for quick debugging.
When sending POST requests, always include -H "Content-Type: application/json" with a JSON body — without it, the server may not parse the body correctly.
Use -w to extract specific metrics from responses: time_total for latency measurement, http_code for scripted status checks.
FAQ
- How do I pretty-print JSON output from curl?
- Pipe the output through a JSON formatter: curl -s URL | python3 -m json.tool or, if jq is installed, curl -s URL | jq . The -s flag suppresses the progress bar so only the JSON appears.
- What is the difference between curl and wget?
- curl supports a wide range of protocols (HTTP, FTP, SMTP, etc.) and excels at API testing with headers and authentication. wget specializes in recursive downloads and website mirroring. For API calls and custom headers, curl is the better choice.
- How do I handle HTTPS certificate errors?
- Use -k (--insecure) to skip certificate verification, but never in production — this makes the connection vulnerable to MITM attacks. For self-signed certificates, specify the CA with --cacert cert.pem instead.