cURL Cheat Sheet

High-coverage curl commands for HTTP requests, APIs, downloads, uploads, cookies, redirects, and automation.

View
StandardDetailedCompact
Export
Copy the compact sheet, download it, or print it.
Download
`D` dense toggle · `C` copy all

Basics and Output

Core requests, saving output, redirects, and response metadata.

GET a URL

Fetch a resource with the default GET method.

bashANYcurlhttpget
bash
curl https://example.com
Notes

The basic curl invocation fetches a URL and prints the response body to stdout.

Follow redirects

Follow HTTP 3xx redirects automatically.

bashANYcurlredirectshttp
bash
curl -L https://example.com
Notes

Use `-L` or `--location` when you expect redirects from short links, login gateways, or moved pages.

Save using remote filename

Download and save using the server-provided path basename.

bashANYcurldownloadoutput
bash
curl -O https://example.com/file.tar.gz
Notes

`-O` uses the remote path basename for the local filename.

Save to a specific file

Write the response body to a local file.

bashANYcurldownloadoutput
bash
curl -o response.html https://example.com
Notes

`-o` lets you control the destination filename.

Include response headers

Print response headers with the response body.

bashANYcurlheadershttp
bash
curl -i https://example.com
Notes

`-i` includes response headers in the output stream.

Fetch headers only

Send a HEAD request to inspect headers without downloading the body.

bashANYcurlheadheaders
bash
curl -I https://example.com
Notes

Useful for checking status, content type, caching headers, or redirects.

Silent mode with errors

Suppress progress meter but still show errors.

bashANYcurlscriptingsilent
bash
curl -sS https://example.com
Notes

`-sS` is a common scripting pattern that keeps output clean while surfacing failures.

Write response metadata

Print status code and timing data after the transfer.

bashANYcurlwrite-outtiming
bash
curl -s -o /dev/null -w 'status=%{http_code} time=%{time_total}
' https://example.com
Notes

`-w` / `--write-out` is great for monitoring, scripts, and diagnostics.

Fail on HTTP errors

Exit non-zero on HTTP 400/500 responses.

bashANYcurlscriptingerrors
bash
curl --fail -sS https://api.example.com/data
Notes

`--fail` is useful in scripts so error responses do not look like success.

Disable URL globbing

Turn off curl URL glob expansion for literal brackets or braces.

bashANYcurlurlglobbing
bash
curl --globoff 'https://example.com/items[1]'
Notes

curl supports URL globbing; `--globoff` disables it when special characters should be treated literally.

Request Shaping

Methods, query strings, headers, cookies, referer, and user agent.

POST with no body

Send a POST request with an empty body.

bashANYcurlpostmethod
bash
curl -X POST https://example.com/resource
Notes

Using `-X POST` changes the method even without request data.

Use a custom HTTP method

Send a method such as PUT, PATCH, DELETE, or PURGE.

bashANYcurlmethodhttp
bash
curl -X DELETE https://example.com/resource/123
Notes

`-X` overrides the request method.

Send query parameters in URL

Pass query parameters directly in the URL.

bashANYcurlqueryurl
bash
curl 'https://example.com/search?q=curl&sort=new'
Notes

Quote URLs containing `&` to prevent shell interpretation.

Append query parameters with --get

Build a GET query string from data parameters.

bashANYcurlqueryget
bash
curl --get --data-urlencode 'q=curl examples' https://example.com/search
Notes

`--get` converts `-d` data into query string parameters.

Send a request header

Add a custom request header.

bashANYcurlheadersapi
bash
curl -H 'Accept: application/json' https://api.example.com/items
Notes

Use `-H` repeatedly to send multiple headers.

Set the User-Agent header

Override the default curl User-Agent.

bashANYcurluser-agentheaders
bash
curl -A 'Mozilla/5.0 test-client' https://example.com
Notes

`-A` / `--user-agent` sets the request's User-Agent.

Set the Referer header

Send a custom Referer header.

bashANYcurlrefererheaders
bash
curl -e 'https://example.com/from' https://example.com/to
Notes

Useful when testing apps that rely on referer checks.

Forms and Upload

Multipart forms, file uploads, binary payloads, and transfer tricks.

Submit a multipart form field

Send a simple form field using multipart/form-data.

bashANYcurlmultipartforms
bash
curl -F 'name=jon' https://example.com/form
Notes

`-F` creates multipart form requests.

Upload a file via multipart form

Attach a file as a multipart upload.

bashANYcurluploadmultipart
bash
curl -F 'file=@./report.pdf' https://example.com/upload
Notes

Prefix a filename with `@` to upload its content.

Upload a file with explicit content type

Specify the filename part and content type.

bashANYcurluploadmultipartmime
bash
curl -F 'file=@./image.png;type=image/png' https://example.com/upload
Notes

Handy when the server expects a precise MIME type.

Upload a file with PUT

Send a local file as the request body with PUT.

bashANYcurlputupload
bash
curl -T ./artifact.zip https://example.com/artifact.zip
Notes

`-T` / `--upload-file` is useful for HTTP, FTP, and other protocols.

Send raw request data

POST a raw string body exactly as provided.

bashANYcurlpostbody
bash
curl --data-raw '{"ok":true}' https://api.example.com/items
Notes

`--data-raw` avoids the special `@` file semantics of `-d`.

Send binary request data

Send binary-safe request data without transformations.

bashANYcurlbinaryupload
bash
curl --data-binary @payload.bin https://api.example.com/upload
Notes

Use this for payloads where newlines and bytes must be preserved.

URL-encode request data

Encode form or query values safely.

bashANYcurlencodingforms
bash
curl --data-urlencode 'message=hello world & more' https://example.com/submit
Notes

This escapes reserved characters for you.

Resume a download

Continue downloading from where a file left off.

bashANYcurlresumedownload
bash
curl -C - -O https://example.com/large.iso
Notes

`-C -` auto-detects the current file size and requests the remainder.

Request a byte range

Download only a specific byte range from a resource.

bashANYcurlrangedownload
bash
curl -r 0-1023 https://example.com/bigfile.bin -o first-kb.bin
Notes

Useful for partial downloads, debugging, and media requests.

Parallel downloads

Download multiple URLs in parallel.

bashANYcurlparalleldownload
bash
curl --parallel --parallel-max 4 -O https://example.com/a.iso -O https://example.com/b.iso
Notes

curl supports parallel transfers in recent versions.

Recommended next

No recommendations yet.