GUIDE深度 · Deep dive

Common cURL Flags

cURL defaults to GET; -X changes the method, -H adds headers, -d adds a body (default POST) and --url sets the address. Shell quoting defines argument boundaries; escape JSON quotes or wrap in single quotes.

更新 2026-10-31 · 公式可核验

Minimal examples

GET: curl https://api.example.com/items

POST JSON: curl -X POST -H 'Content-Type: application/json' -d '{"a":1}' URL

Debugging

-i shows response headers, -v shows handshake/request headers.

--data-raw prevents @ from being treated as a file.

FAQ

Why does -d become POST?

That is curl's default; add -G for GET.

Which quotes?

Wrap JSON in single quotes so inner double quotes need no escaping (bash).

Sources

Related calculators

cURL to CodePaste cURL to generate fetch, axios or Python requests code; parses URL, method, headers and body without sending requests.

More guides

cURL to fetch/axios PitfallsRead guide