8 min read
What is cURL used for
cURL is a command-line tool for making network requests, testing APIs, and sharing reproducible request examples.
Table of contents
cURL basics
cURL is a command-line tool for making network requests. Developers use it to test APIs, reproduce bugs, inspect headers, download resources, and share exact request examples across teams.
Because a cURL command includes method, URL, headers, and body in one place, it can be more precise than a paragraph describing what someone clicked in a UI.
Common flags
-X sets the HTTP method, -H adds a header, and -d or --data sends a request body. A JSON POST request often combines all three: method POST, Content-Type: application/json, and a JSON body.
Long cURL commands can be hard to read when compressed into one line. Formatting them across multiple lines makes headers and data easier to inspect.
Using cURL for debugging
cURL is useful when you need to separate frontend behavior from API behavior. If a request fails in the app but succeeds in cURL, the issue may be client code, browser state, CORS, or credentials. If it fails in both, the request or server may be the problem.
Always capture status code, headers, and body when debugging. The response metadata often explains the failure faster than the body alone.
Related guides
URL encoding explained
URL encoding protects values inside URLs so reserved characters are interpreted as data instead of syntax.
SHA256 vs MD5
SHA-256 is a modern cryptographic hash. MD5 remains common in legacy checks but is broken for security uses.
HTTP status codes explained
HTTP status codes quickly tell you whether a request succeeded, redirected, failed client-side, or failed server-side.
FAQ
Does cURL only work with HTTP?
No. cURL supports many protocols, but developers commonly use it for HTTP APIs.
Why do API docs show cURL?
cURL examples are portable, explicit, and easy to run from a terminal.
Can cURL send JSON?
Yes. Use headers such as Content-Type: application/json and a request body with --data.
Should I share cURL commands with tokens?
No. Redact Authorization headers, cookies, and secrets before sharing.