cURL basics
What is a cURL command?
A curl command is a terminal instruction that describes an HTTP request or another URL transfer in a repeatable text format.
Anatomy of a curl command
Most curl commands include three parts: the curl program, the target URL, and optional flags. The URL says where the request goes. The flags say how the request should behave.
Those flags can set the HTTP method, add headers, send a request body, attach credentials, upload files, or control redirects and timeouts.
Example with method, header, and body
This example creates a user by sending JSON to an API endpoint. The command uses -X to set the method, -H to add a header, and -d to send the JSON body.
curl -X POST https://api.example.com/users \
-H "Content-Type: application/json" \
-d '{"name":"Ada","email":"[email protected]"}'Why curl commands are useful
A curl command is easy to copy, paste, save in a bug report, or share with another developer. It captures the request clearly enough that someone else can reproduce it.
That is why curl commands appear in API documentation, support tickets, browser DevTools, logs, and engineering notes.
From curl to application code
A curl command is great for testing, but most apps need code. Once the request works in curl, you can translate it into a language-specific HTTP client such as Python requests, JavaScript fetch, Node Axios, Go net/http, or PHP cURL.
Try it with curlcode
Have a curl command already? Paste it into one of the converters below to generate language-specific HTTP request code.
Frequently asked questions
Do curl commands only work for HTTP?
No. curl supports many protocols, but most developer examples use HTTP or HTTPS.
What does -H mean in curl?
-H adds a request header, such as Content-Type, Authorization, or Accept.
What does -d mean in curl?
-d sends request data, commonly a JSON payload or form data.
Can I run curl on Windows?
Yes. Modern Windows includes curl, and it is also available on macOS and Linux.
Related guides
What does cURL mean?
Learn what cURL means, why developers use it, and how a simple curl command turns a URL into a repeatable API request.
How to copy as cURL from Chrome DevTools
Use Chrome DevTools to copy a real browser request as cURL, inspect headers and cookies, and convert it into reusable code.
How to send a POST request with JSON using cURL
Learn how to send JSON with curl using POST, Content-Type headers, and request bodies that APIs can parse correctly.