curl Cheat Sheet

A reference for curl, making GET and POST requests, sending headers and JSON, handling authentication, following redirects, downloading files, and inspecting responses.

A quick reference to curl, the command-line HTTP client. Replace URL with your address. Flags can be combined, and most work on every protocol curl speaks (HTTP, HTTPS, FTP, and more).

Basic requests

CommandWhat it does
curl URLGET a URL and print the body
curl -L URLFollow redirects (3xx)
curl -i URLInclude the response headers
curl -s URLSilent mode (hide the progress meter)
curl -v URLVerbose: show request, response, and handshake

Methods & data

CommandWhat it does
curl -X POST URLUse a specific HTTP method
curl -d "a=1&b=2" URLSend form-encoded POST data
curl --json '{"k":"v"}' URLSend JSON (sets method, type, and body)
curl -d @file.json URLSend the contents of a file as the body

Headers & auth

CommandWhat it does
curl -H "X-Api-Key: 123" URLAdd a custom request header
curl -u user:pass URLBasic authentication
curl -H "Authorization: Bearer TOKEN" URLBearer token (OAuth / JWT)
curl -b cookies.txt URLSend cookies from a file
curl -c cookies.txt URLSave response cookies to a file

Downloading

CommandWhat it does
curl -O URLSave to a file named after the URL
curl -o out.zip URLSave to a file you name
curl -C - -O URLResume an interrupted download
curl -I URLFetch headers only (HEAD request)

TLS & timing

CommandWhat it does
curl -k URLSkip TLS certificate verification (insecure)
curl --cert client.pem URLUse a client certificate for mTLS
curl -w "%{http_code}\n" -o /dev/null -s URLPrint just the HTTP status code
curl --max-time 10 URLGive up after 10 seconds

Tip: pair -s (silent) with -S to keep error messages while hiding the meter, and use -w to print timings like %{time_total} when you are debugging slow requests.

What this does

A curl cheat sheet covers making GET and POST requests, sending headers and JSON, authentication, redirects, downloads, and inspecting responses.

How to use it

  1. Browse by section.
  2. Find the command you need.
  3. Copy it with one tap.
  4. Swap in your URL and options.

Example

curl -O https://example.com/file.zip downloads a file keeping its name.

Sources & methodology

Last updated .

Frequently asked questions

How is curl different from wget?

Both fetch URLs, but wget is download-focused and can recurse a whole site, while curl speaks many more protocols and is better for crafting requests with headers, data, and auth.

How do I send a JSON POST request?

Use -X POST with -H "Content-Type: application/json" and pass the JSON body with -d. In modern curl, the --json flag does all three at once.

How do I see the request and response headers?

Add -i to print the response headers, or -v (verbose) to show both the request and the response, including the TLS handshake.