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. Most flags here are for HTTP(S), though curl speaks many more protocols (FTP, SFTP, and others).

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 (hides the progress meter and error messages)
curl -v URLVerbose: show request and response headers plus connection details

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"}' URLPOST JSON with Content-Type and Accept set to application/json (curl 7.82+)
curl --data-binary @file.json URLSend a file as the body exactly as-is (-d @file strips newlines; --json @file.json also sets the JSON headers)

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.

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?

Pass the JSON body with -d (which already makes the request a POST) and add -H "Content-Type: application/json". In curl 7.82 and later, --json does this in one flag and also sets Accept: application/json.

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 response headers plus extra connection details.