Curl Cheatsheet
cURL is a powerful and versatile command-line tool for transferring data with URLs. It supports a wide range of protocols including HTTP, HTTPS, FTP, and more. cURL is widely used by developers and system administrators for testing APIs, automating file downloads and uploads, debugging network issues, and scripting complex data transfers. Its flexibility and extensive options make it an essential tool for web development, DevOps, and cloud workflows.
This cheatsheet provides a comprehensive and practical reference for common curl commands. It covers HTTP requests, authentication, headers, cookies, data transfer, and more. Use it to boost your productivity and master curl workflows.
cURL Cheatsheet
HTTP client commands for API testing
Commands
Categories
Favorites
Sections
curl https://example.comSimple GET request
curl -o file.html https://example.comSave output to file
curl -O https://example.com/file.zipSave with original filename
curl -L https://example.comFollow redirects
curl -I https://example.comFetch headers only (HEAD)
curl -i https://example.comInclude response headers
curl -s https://example.comSilent mode (no progress)
curl -v https://example.comVerbose output
curl -w '%{http_code}' https://example.comShow HTTP status code
curl -w '%{time_total}' https://example.comShow total time
curl -X GET https://api.example.com/usersGET request (default)
curl -X POST https://api.example.com/usersPOST request
curl -X PUT https://api.example.com/users/1PUT request
curl -X PATCH https://api.example.com/users/1PATCH request
curl -X DELETE https://api.example.com/users/1DELETE request
curl -d 'key=value' https://example.comSend form data (POST)
curl -d 'key1=val1&key2=val2' https://example.comMultiple form fields
curl -d @data.txt https://example.comSend data from file
curl --data-urlencode 'key=value with spaces' https://example.comURL-encode data
curl -H 'Content-Type: application/json' https://example.comSet Content-Type
curl -H 'Accept: application/json' https://example.comSet Accept header
curl -H 'X-Custom: value' https://example.comCustom header
curl -A 'Mozilla/5.0' https://example.comSet User-Agent
curl -e 'https://referrer.com' https://example.comSet Referer header
curl -H 'Content-Type: application/json' -d '{"name":"John"}' https://api.example.comPOST JSON data
curl -H 'Content-Type: application/json' -d @data.json https://api.example.comPOST JSON from file
💡 Always set Content-Type header when sending JSON
curl -u user:pass https://example.comBasic authentication
curl -u user https://example.comBasic auth (prompt for password)
curl --digest -u user:pass https://example.comDigest authentication
curl -H 'Authorization: Bearer TOKEN' https://api.example.comBearer token
curl -H 'X-API-Key: YOUR_KEY' https://api.example.comAPI key header
curl -b 'name=value' https://example.comSend cookie
curl -c cookies.txt https://example.comSave cookies to file
curl -b cookies.txt https://example.comLoad cookies from file
curl -b cookies.txt -c cookies.txt https://example.comLoad and save cookies
💡 Use -b and -c together to maintain session
curl -k https://example.comAllow insecure SSL
curl --cacert ca.crt https://example.comUse custom CA certificate
curl --cert client.crt --key client.key https://example.comClient cert with key
curl --tlsv1.2 https://example.comForce TLS 1.2
curl --tlsv1.3 https://example.comForce TLS 1.3
curl -x http://proxy:8080 https://example.comUse HTTP proxy
curl -x socks5://proxy:1080 https://example.comUse SOCKS5 proxy
curl --resolve example.com:443:1.2.3.4 https://example.comCustom DNS resolution
curl --connect-timeout 10 https://example.comConnection timeout (seconds)
curl -m 30 https://example.comMax time for operation
curl --limit-rate 100k https://example.com/file.zipLimit download speed
curl --retry 3 https://example.comRetry on failure
curl -F '[email protected]' https://example.com/uploadUpload file (multipart)
curl -T file.txt https://example.com/uploadPUT upload
curl -s https://api.example.com/users | jq .Pretty print JSON response
curl -s -o /dev/null -w '%{http_code}' https://example.comGet only status code
curl -s -w '\nTime: %{time_total}s\n' https://example.comShow response time
curl -C - -O https://example.com/file.zipResume download
curl -r 0-999 https://example.com/file.zipDownload first 1000 bytes
Quick Reference
curl URL
curl -d 'data' URL
curl -H 'Key: Val' URL
curl -u user:pass URL
Categories
- Basic Usage
Simple GET requests, download files, and view responses.
- HTTP Methods
Use different HTTP methods like POST, PUT, DELETE, etc.
- Headers & Cookies
Set custom headers, user agents, and manage cookies.
- Authentication
Use basic, bearer, and other authentication methods.
- Data Transfer
Send data as form, JSON, or upload files.
- Advanced Usage
Advanced options, debugging, proxies, and more.
Features
- Quick search functionality
- Organized by categories
- Clear command descriptions
- Common and advanced use cases covered
- Easy to copy commands
- Responsive design
- Perfect for quick reference