CURL Commands Cheatsheet — Essential Reference

curl is a command-line tool for transferring data with URLs, supporting a wide range of protocols including HTTP, HTTPS, FTP, and more. It's commonly used for testing APIs, downloading files, and interacting with web services.

Last updated: 2026-06-11

RECOMMENDED

Secure Your Connection with NordVPN

Protect your SSH sessions and network traffic with the gold standard in VPN security. Get up to 60% off.

Get NordVPN Security →

Commands

Command Description Example
curl [URL] Basic GET request to a URL, displaying the response body to stdout. curl https://api.github.com/users/octocat
curl -O [URL] Download a file and save it with its original filename. curl -O https://example.com/archive.zip
curl -o [filename] [URL] Download a file and save it with a specified filename. curl -o my_download.html https://example.com
curl -X POST -d 'key=value&key2=value2' [URL] Send a POST request with URL-encoded form data. curl -X POST -d 'username=user&password=pass' https://api.example.com/login
curl -X POST -H 'Content-Type: application/json' -d '{"name":"John Doe"}' [URL] Send a POST request with JSON data and set the Content-Type header. curl -X POST -H 'Content-Type: application/json' -d '{"title":"New Post","body":"This is a new post."}' https://jsonplaceholder.typicode.com/posts
curl -I [URL] Perform a HEAD request, showing only the HTTP headers. curl -I https://www.google.com
curl -u [username]:[password] [URL] Send a request with basic HTTP authentication. curl -u admin:secretpassword https://api.example.com/protected
curl -L [URL] Follow HTTP 3xx redirects. curl -L http://shorturl.at/abcde

Pro Tips

  • Use `curl -v` for verbose output, showing request and response headers, and connection details.
  • Pipe `curl` output to other tools like `jq` for JSON parsing: `curl https://api.github.com/users/octocat | jq .login`.
  • For debugging, use `--trace-ascii debug.log` to log all incoming and outgoing data in a human-readable format.

Frequently Asked Questions

What is curl used for?

curl is primarily used for making HTTP requests (GET, POST, PUT, DELETE, etc.), downloading files, testing APIs, and interacting with various network protocols from the command line.

How do I install curl?

curl is pre-installed on most Unix-like operating systems (Linux, macOS). On Windows, it's often available by default in recent versions or can be installed via package managers like Chocolatey (`choco install curl`) or by downloading from the official website.