curl Commands

curl commands cheatsheet.

Fetch URLs, post data, set headers and debug HTTP from the terminal — the curl flags you actually use. Tap to copy.

Fetching
curl https://example.comFetch a URL and print the response
curl -O https://example.com/file.zipDownload and save with the remote filename
curl -o out.html https://example.comDownload and save to a chosen filename
curl -L https://example.comFollow redirects to the final URL
curl -I https://example.comFetch only the response headers
curl -s https://example.comSilent mode — hide the progress meter
Sending data
curl -X POST https://api.example.comMake a request with a specific method
curl -d "name=ada&role=dev" URLSend form-encoded POST data
curl -H "Content-Type: application/json" -d '{"a":1}' URLSend a JSON request body
curl -d @data.json URLSend the contents of a file as the body
curl -F "file=@photo.png" URLUpload a file as multipart form data
Headers & auth
curl -H "Authorization: Bearer TOKEN" URLSend a custom header (e.g. a bearer token)
curl -u user:pass URLUse HTTP basic authentication
curl --cookie "session=abc" URLSend a cookie with the request
curl -A "MyAgent/1.0" URLSet a custom User-Agent
Debugging
curl -v https://example.comVerbose output — show the full exchange
curl -w "%{http_code}\n" -o /dev/null -s URLPrint just the HTTP status code
curl --max-time 10 URLGive up after 10 seconds
curl -k https://example.comSkip TLS certificate verification (insecure)

The everyday HTTP tool

curl is how you talk to web servers and APIs from the command line. A bare curl URL prints a response; add -L to follow redirects, -I for just the headers, and -O to save a download. For APIs, -X sets the method, -d sends a body, and -H adds headers like an auth token. When something misbehaves, -v shows the entire request and response so you can see exactly what's happening.

FAQ

How do I send JSON with curl?
Set the content type and pass the body: curl -H "Content-Type: application/json" -d '{"key":"value"}' URL.
How do I download a file with curl?
Use curl -O URL to save it with its remote name, or curl -o name.ext URL to choose the filename. Add -L to follow redirects.

More cheatsheets