Command builder
curl command builder
For the things you only do occasionally — check response headers, follow redirects, debug CORS, test caching. Pick a recipe, tweak, copy. Quoting is correct for your shell.
Response & inspection
Headers & identity
Custom headers
Authentication
Request body
Form fields (value @path uploads a file)
CORS preflight
Caching / conditional
TLS & connection
Resolve host to a specific IP --resolve (test a CDN edge / staging server)
The recipes, explained
- Headers only —
-I - Sends a
HEADrequest and prints just the response headers. The classic confusion:-I= headers only;-i= headers plus body. Don't use-X HEAD— it can hang waiting for a body that never comes. - Trace redirects —
-sIL - Follows the redirect chain (
-L) and prints each hop's headers (-I), quietly (-s). The fastest way to see where a URL really ends up and with which status codes. Note: by default curl does not follow redirects. - Test CORS — preflight
OPTIONS - Browsers send a preflight before certain cross-origin requests. This reproduces it: an
OPTIONSrequest carryingOrigin,Access-Control-Request-MethodandAccess-Control-Request-Headers. Read the response'sAccess-Control-Allow-*headers to see what the server permits. - Test caching — conditional request
- Send the
ETagyou got back asIf-None-Match(or a date asIf-Modified-Since). A304 Not Modifiedconfirms caching/revalidation works. InspectCache-Control,Expires,Ageand CDN headers likeX-Cache/CF-Cache-Statusin the headers-only view. - POST JSON —
-d+Content-Type - The #1 mistake is forgetting
Content-Type: application/json, so this recipe adds it automatically.-dalready impliesPOST, so no separate-X POSTis emitted. - Timing breakdown —
-w - Prints DNS, connect, TLS, time-to-first-byte and total times — for answering "why is this slow?" without a profiler.
Why the shell toggle?
bash/zsh wrap strings in single quotes, so JSON like {"a":1} pastes cleanly. Windows shells don't: CMD has no single-quote string, so quotes must be doubled and inner ones escaped; PowerShell aliases curl to a different command, so the binary is written as curl.exe, and the null device is NUL not /dev/null. Pick your shell and the command is rewritten to paste correctly.
Two security notes
-k (skip TLS verification) defeats the point of HTTPS — use it only against known staging/self-signed hosts, never in scripts that touch real data. On a redirect to a different host, curl drops the Authorization header on purpose so your token can't leak to another origin.
Sources & references
- everything.curl.dev — the curl bookcurl project
- curl man pagecurl.se
- Cross-Origin Resource Sharing (CORS)MDN
- HTTP cachingMDN