curl Cheat Sheet
Transfer data over HTTP(S) and more — headers, timeouts, auth, multipart uploads, and getting just the parts you need.
Networking4 sections · 29 commands
⌘K
Basic Requests
8curl URLGET and dump the body
curl -o FILE URLSave output to a file
curl -o /dev/null -w '%{http_code}\n' URLJust the status code
curl -L URLFollow redirects
curl -I URLHEAD request, headers only
curl --max-time 10 URLAbort after 10 seconds
curl --connect-timeout 5 URLTimeout for connecting
curl --retry 3 --retry-all-errors URLRetry transient failures
POST, PUT & JSON
6curl -X POST -d 'key=value' URLURL-encoded form POST
curl -X POST -H 'Content-Type: application/json' -d '{"k":"v"}' URLJSON POST
curl -X PUT -d @file.json URLPUT from a file
curl -X DELETE URLDELETE request
curl -X POST -F 'file=@local.png' -F 'note=hi' URLMultipart upload
curl -X PATCH -d '{"k":"v"}' URLPATCH with body
Auth & Headers
7curl -H 'Authorization: Bearer TOKEN' URLBearer token header
curl -u USER:PASS URLHTTP basic auth
curl -b 'Cookie: session=abc' URLSend a cookie
curl -c cookies.txt URLSave cookies to a jar
curl -b cookies.txt URLLoad cookies from a jar
curl --cert cert.pem --key key.pem URLMutual TLS (mTLS)
curl -u USER -H 'X-Pretty-Print: 1' https://api.github.com/repos/org/repoHeaders + basic auth combo
Debugging
8curl -v URLVerbose request/response trace
curl -sv URL 2>&1 | grep '^\*'Only the TLS/handshake lines
curl --resolve example.com:443:127.0.0.1 URLOverride DNS for testing
curl -k URLSkip TLS certificate checks (test only)
curl --http2 URLForce HTTP/2
curl -x http://PROXY:PORT URLRoute through a proxy
curl -w 'dns:%{time_namelookup} tcp:%{time_connect} tls:%{time_appconnect} total:%{time_total}\n' -o /dev/null -s URLPer-phase timing breakdown
curl -s URL | jq .Pretty-print JSON output