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
GET a URL
curl https://example.com

# Fetch a resource with the default GET method.

Follow redirects
curl -L https://example.com

# Follow HTTP 3xx redirects automatically.

Save using remote filename
curl -O https://example.com/file.tar.gz

# Download and save using the server-provided path basename.

Save to a specific file
curl -o response.html https://example.com

# Write the response body to a local file.

Include response headers
curl -i https://example.com

# Print response headers with the response body.

Fetch headers only
curl -I https://example.com

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

Silent mode with errors
curl -sS https://example.com

# Suppress progress meter but still show errors.

Write response metadata
curl -s -o /dev/null -w 'status=%{http_code} time=%{time_total}
' https://example.com

# Print status code and timing data after the transfer.

Fail on HTTP errors
curl --fail -sS https://api.example.com/data

# Exit non-zero on HTTP 400/500 responses.

Disable URL globbing
curl --globoff 'https://example.com/items[1]'

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

## Request Shaping
POST with no body
curl -X POST https://example.com/resource

# Send a POST request with an empty body.

Use a custom HTTP method
curl -X DELETE https://example.com/resource/123

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

Send query parameters in URL
curl 'https://example.com/search?q=curl&sort=new'

# Pass query parameters directly in the URL.

Append query parameters with --get
curl --get --data-urlencode 'q=curl examples' https://example.com/search

# Build a GET query string from data parameters.

Send a request header
curl -H 'Accept: application/json' https://api.example.com/items

# Add a custom request header.

Set the User-Agent header
curl -A 'Mozilla/5.0 test-client' https://example.com

# Override the default curl User-Agent.

Set the Referer header
curl -e 'https://example.com/from' https://example.com/to

# Send a custom Referer header.

## Forms and Upload
Submit a multipart form field
curl -F 'name=jon' https://example.com/form

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

Upload a file via multipart form
curl -F 'file=@./report.pdf' https://example.com/upload

# Attach a file as a multipart upload.

Upload a file with explicit content type
curl -F 'file=@./image.png;type=image/png' https://example.com/upload

# Specify the filename part and content type.

Upload a file with PUT
curl -T ./artifact.zip https://example.com/artifact.zip

# Send a local file as the request body with PUT.

Send raw request data
curl --data-raw '{"ok":true}' https://api.example.com/items

# POST a raw string body exactly as provided.

Send binary request data
curl --data-binary @payload.bin https://api.example.com/upload

# Send binary-safe request data without transformations.

URL-encode request data
curl --data-urlencode 'message=hello world & more' https://example.com/submit

# Encode form or query values safely.

Resume a download
curl -C - -O https://example.com/large.iso

# Continue downloading from where a file left off.

Request a byte range
curl -r 0-1023 https://example.com/bigfile.bin -o first-kb.bin

# Download only a specific byte range from a resource.

Parallel downloads
curl --parallel --parallel-max 4 -O https://example.com/a.iso -O https://example.com/b.iso

# Download multiple URLs in parallel.

Recommended next

No recommendations yet.